當前位置: 首頁>>代碼示例>>Java>>正文


Java UIComponent.getFacets方法代碼示例

本文整理匯總了Java中javax.faces.component.UIComponent.getFacets方法的典型用法代碼示例。如果您正苦於以下問題:Java UIComponent.getFacets方法的具體用法?Java UIComponent.getFacets怎麽用?Java UIComponent.getFacets使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.component.UIComponent的用法示例。


在下文中一共展示了UIComponent.getFacets方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createComponent

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Re-create a component from a structure object
 */
@SuppressWarnings("unchecked")
public UIComponent createComponent()
  throws ClassNotFoundException, InstantiationException,
         IllegalAccessException
{
  Class<?> clazz = ClassLoaderUtils.loadClass(_class);
  UIComponent component = (UIComponent) clazz.newInstance();
  if (_id != null)
    component.setId(_id);
  // Create any facets
  if (_facets != null)
  {
    Map<String, UIComponent> facets = component.getFacets();
    for (int i = 0 ; i < _facets.size(); i += 2)
    {
      UIComponent facet = ((Structure) _facets.get(i + 1)).
                               createComponent();
      facets.put((String)_facets.get(i), facet);
    }
  }

  // Create any children
  if (_children != null)
  {
    List<UIComponent> children = component.getChildren();
    for (int i = 0 ; i < _children.size(); i++)
    {
      UIComponent child = _children.get(i).createComponent();
      children.add(child);
    }
  }

  return component;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:38,代碼來源:Structure.java

示例2: _getFacets

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Store the structure of all the facets.
 */
@SuppressWarnings("unchecked")
private List<Object> _getFacets(UIComponent component)
{
  Iterator<String> facetNames;
  if (component instanceof UIXComponentBase)
  {
    facetNames = ((UIXComponentBase) component).getFacetNames();
  }
  else
  {
    facetNames = component.getFacets().keySet().iterator();
  }

  if (!facetNames.hasNext())
    return null;

  Map<String, UIComponent> facets = component.getFacets();
  ArrayList<Object> list = new ArrayList<Object>(facets.size() * 2);
  while (facetNames.hasNext())
  {
    String name = facetNames.next();
    UIComponent facet = facets.get(name);
    if ((facet != null) && !facet.isTransient())
    {
      list.add(name);
      list.add(new Structure(facet));
    }
  }

  if (list.isEmpty())
    return null;

  return list;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:38,代碼來源:Structure.java

示例3: _addChildren

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void _addChildren(FacesContext context, UIComponent component)
{
  // If the components are already there, bail.
  if (component.getFacet("month") != null)
    return;

  String id = component.getId();
  if (id == null)
  {
    id = context.getViewRoot().createUniqueId();
    component.setId(id);
  }

  Map<String, UIComponent> facets = component.getFacets();
  facets.clear();

  Date value = (Date) ((EditableValueHolder) component).getValue();
  Calendar calendar = null;
  if(value != null)
  {
    calendar = Calendar.getInstance();
    calendar.setLenient(true);
    calendar.setTime(value);
  }

  CoreInputText month = _createTwoDigitInput(context);
  month.setShortDesc("Month");
  month.setId(id + "_month");

  LongRangeValidator monthRange = _createLongRangeValidator(context);
  monthRange.setMinimum(1);
  monthRange.setMaximum(12);
  month.addValidator(monthRange);
  if (value != null)
    month.setValue(new Integer(calendar.get(Calendar.MONTH) + 1));
  facets.put("month", month);

  CoreInputText day = _createTwoDigitInput(context);
  day.setShortDesc("Day");
  day.setId(id + "_day");
  LongRangeValidator dayRange = _createLongRangeValidator(context);
  dayRange.setMinimum(1);
  dayRange.setMaximum(31);
  day.addValidator(dayRange);
  if (value != null)
    day.setValue(new Integer(calendar.get(Calendar.DAY_OF_MONTH)));
  facets.put("day", day);

  CoreInputText year = _createTwoDigitInput(context);
  year.setShortDesc("Year");
  year.setId(id + "_year");
  if (value != null)
  {
    int yearValue = calendar.get(Calendar.YEAR) - 1900;
    if (yearValue >= 100)
      yearValue -= 100;
    year.setValue(new Integer(yearValue));
  }

  facets.put("year", year);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:63,代碼來源:DateFieldAsRenderer.java

示例4: removeFacets

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Removes one or more facets, based on some characteristic of the
 *  event source.
 */
@SuppressWarnings("unchecked")
public void removeFacets(ActionEvent event)
{
  CoreCommandButton eventSource = (CoreCommandButton) event.getComponent();
  //pu: Anything until ":" in the button text represents the facet name/s
  String facetNameFromButtonText = (eventSource.getText().split(":"))[0];
  //pu: In case of the button that removes multiple facets, this is again 
  //  delimited by "_"
  String removableFacetNames[] = facetNameFromButtonText.split("_");
  
  //pu: Get the CorePanelPage components that has all the removable facets
  UIComponent uic = eventSource.findComponent("pp1");
  Map<String, UIComponent> facets = uic.getFacets();
  if (facets.keySet().size() == 0)
    return;

  for (int i=0; i<removableFacetNames.length; i++)
  {
    if (facets.get(removableFacetNames[i]) != null)
    {
      facets.remove(removableFacetNames[i]);
      ComponentChange rfa = new RemoveFacetComponentChange(removableFacetNames[i]);
      FacesContext fc = FacesContext.getCurrentInstance();
      ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
      apm.addComponentChange(fc, uic, rfa);
    }
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:33,代碼來源:ChangeBean.java

示例5: changeComponent

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public void changeComponent(UIComponent uiComponent)
{
  Map<String, UIComponent> facets = uiComponent.getFacets();
  facets.remove(_facetName);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:11,代碼來源:RemoveFacetComponentChange.java

示例6: __removeFromParent

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
static int __removeFromParent(
  UIComponent component,
  int index)
{
  UIComponent parent = component.getParent();
  assert(parent != null);

  if (parent.getChildCount() > 0)
  {
    List<UIComponent> children = parent.getChildren();
    int size = children.size();
    for  (int i = 0; i < size; i++)
    {
      if  (children.get(i) == component)
      {
        children.remove(i);
        if (index > i)
          index--;
        return index;
      }
    }
  }
  
  // TRINIDAD-2369: Until TRINIDAD-2368 is fixed, we have to call remove() on the map
  // returned by getFacets() rather than calling remove() on getFacets().values()
  // Note that the old code used to call getFacets().values().contains(), which would iterate on the entry set.
  // The new code performs the same iteration, so it should not be any slower.
  
  Map<String, UIComponent> facets = parent.getFacets();
  for (Map.Entry<String, UIComponent> entry: facets.entrySet())
  {
    if (entry.getValue() == component)
    {
      facets.remove(entry.getKey());
      return index;
    }
  }

  // Not good - the child thought it was in a parent,
  // but it wasn't.
  assert(false);
  return index;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:45,代碼來源:ChildArrayList.java


注:本文中的javax.faces.component.UIComponent.getFacets方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。