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


Java UIComponent.findComponent方法代碼示例

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


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

示例1: modifyColumn

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Modifies the sortable property of the column.
 */
@SuppressWarnings("unchecked")
public void modifyColumn(ActionEvent event)
{
  //=-=pu: 'uic1' gets null, while 'uic' gets valid component, maybe a bug ?.
  //UIComponent uic1 = event.getComponent().findComponent("c1");
  UIComponent uic2 = event.getComponent().findComponent("t1");
  UIComponent uic = uic2.findComponent("c1");
  
  Object sortableAttrib = uic.getAttributes().get("sortable");
  Boolean isSortable = 
    (sortableAttrib == null)? Boolean.TRUE:(Boolean)sortableAttrib;
  Boolean newSortableValue = 
    Boolean.TRUE.equals(isSortable)? Boolean.FALSE:Boolean.TRUE;
  uic.getAttributes().put("sortable", newSortableValue);
  _addAttributeChange(uic, "sortable", newSortableValue);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:20,代碼來源:ChangeBean.java

示例2: appendChildToDocument

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Appends an image child to the panelGroup in the underlying JSP document
 */
public void appendChildToDocument(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  
  // only allow the image to be added once
  if (_findChildById(uic,"oi3") != null)
    return;
    
  FacesContext fc = FacesContext.getCurrentInstance();

  DocumentFragment imageFragment = _createDocumentFragment(_IMAGE_MARK_UP);
  
  if (imageFragment != null)
  {
    DocumentChange change = new AddChildDocumentChange(imageFragment);
    
    ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
    
    apm.addDocumentChange(fc, uic, change);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:26,代碼來源:ChangeBean.java

示例3: appendChild

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Appends an image child to the panelGroup.
 */
@SuppressWarnings("unchecked")
public void appendChild(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  if (_findChildById(uic,"oi2") != null)
    return;
  FacesContext fc = FacesContext.getCurrentInstance();
  
  CoreImage newChild = 
    (CoreImage) fc.getApplication().createComponent(
      "org.apache.myfaces.trinidad.CoreImage");
  newChild.setId("oi2");
  newChild.setInlineStyle("height: 100px, width: 120px");
  newChild.setSource(
    "http://homepage.mac.com/awiner/.Pictures/WindyHill/PaleSwallowtail.jpg");  
  uic.getChildren().add(newChild);

  ComponentChange aca = new AddChildComponentChange(newChild);

  ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
  apm.addComponentChange(fc, uic, aca);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:27,代碼來源:ChangeBean.java

示例4: addFacet

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Adds a 'brandingAppContextual' facet  to the panelGroup.
 */
@SuppressWarnings("unchecked")
public void addFacet(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pp1");
  FacesContext fc = FacesContext.getCurrentInstance();
  CoreOutputFormatted newFacetComponent = 
    (CoreOutputFormatted) fc.getApplication().createComponent(
      "org.apache.myfaces.trinidad.CoreOutputFormatted");
  newFacetComponent.setStyleUsage("inContextBranding" );
  newFacetComponent.setValue(
    "Customer Company - Menlo Park");
  uic.getFacets().put("brandingAppContextual", newFacetComponent);

  ComponentChange afa = new SetFacetChildComponentChange("brandingAppContextual", newFacetComponent);

  ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
  apm.addComponentChange(fc, uic, afa);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:ChangeBean.java

示例5: removeChildren

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Removes a pair of children, based on some characteristic of the
 *  event source.
 */
public void removeChildren(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  int numChildren = uic.getChildCount();
  if (numChildren == 0)
    return;
  String eventSourceId = eventSource.getId();    
  if (eventSourceId.equals("cb2"))
  {
    _removeChild(uic, "sic1");
    _removeChild(uic, "cc1");
  }
  else if (eventSourceId.equals("cb3"))
  {
    _removeChild(uic, "cd1");
    _removeChild(uic, "sid1");
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:24,代碼來源:ChangeBean.java

示例6: restoreFacet

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void restoreFacet(UIComponent region, String facet)
{
  UIComponent relocatedFacet = _facet;
  if (relocatedFacet == null)
  {
    relocatedFacet = region.findComponent(_findId);
  }
  region.getFacets().put(facet, relocatedFacet);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:11,代碼來源:ComponentRefTag.java

示例7: temporaryMoveComponent

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
public void temporaryMoveComponent(ActionEvent ae)
{
  System.out.println("Temporarily moving a component");
  UIComponent button = ae.getComponent();
  UIComponent moveme = button.findComponent("moveme");
  UIComponent moveto = button.findComponent("moveto");
  UIComponent parent = moveme.getParent();
  
  parent.getChildren().remove(moveme);
  moveto.getChildren().add(moveme);
  moveto.getChildren().remove(moveme);
  parent.getChildren().add(moveme);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:14,代碼來源:TestStateSavingBean.java

示例8: getFullOnkeypress

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
protected String getFullOnkeypress(
  FacesContext context,
  UIComponent  component,
  FacesBean    bean,
  String       clientId)
{
  String onKeypress = super.getOnkeypress(component, bean);

  String defaultCommand = getDefaultCommand(component, bean);

  String submitFunc = null;

  UIComponent defaultCommandComponent = null;
  if (defaultCommand != null && !"".equals(defaultCommand))
  {
    defaultCommandComponent
      = component.findComponent(defaultCommand);
  }

  if (defaultCommandComponent != null && (defaultCommandComponent instanceof ActionSource))
  {
    // Get the true clientId
    String defaultCommandId =
      defaultCommandComponent.getClientId(context);
    int immediate = 1;

    if(((ActionSource) defaultCommandComponent).isImmediate())
    {
      immediate = 0;
    }

    //PPR
    Boolean ppr = (Boolean) defaultCommandComponent.getAttributes().get("partialSubmit");
    if(ppr != null && ppr)
    {
      submitFunc = "return _submitOnEnter"
          + "(event,'"  + clientId
          + "'," + "'" + defaultCommandId
          + "'," + immediate
          + "," + true +");";
    }
    //no PPR
    else
    {
      submitFunc = "return _submitOnEnter"
          + "(event,'"  + clientId
          + "'," + "'" + defaultCommandId
          + "'," + immediate
          + "," + false +");";
    }
  }
  else
  {
    submitFunc = "return _submitOnEnter(event,'" +
                           clientId +
                           "');";
  }

  onKeypress = XhtmlUtils.getChainedJS(onKeypress, submitFunc, true);

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

示例9: apply

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void apply(FacesContext context, UIComponent component)
{
  Iterator<Test> tests = _delegateTests.iterator();
  
  if (_testComponentId != null)
    component = component.findComponent(_testComponentId); 
  
  while (tests.hasNext())
  {
    Test test = tests.next();
    test.apply(context, component);
  }
  
  Object value = _value;
  
     
  // Hack to test table sort. This is a custom attribute not renderer or component attribute
  if ("tableSortCriteria".equals(_name))
  {
    UIXCollection tableModel = (UIXCollection)  component;
    List<SortCriterion> sortCriteriaList = new ArrayList<SortCriterion>();
    String sortCriterion = (String) _value;
    Boolean isAscending  = 
       new Boolean(sortCriterion.substring(sortCriterion.indexOf(" ")).trim());
    sortCriteriaList.add(new SortCriterion(
          sortCriterion.substring(0,sortCriterion.indexOf(" ")), 
          isAscending.booleanValue()));
    tableModel.setSortCriteria(sortCriteriaList);
  }
  else
  {      
    if ((value instanceof String) &&
        ComponentDefinition.isValueExpression(value.toString()))
    {
      ValueBinding binding = context.getApplication().
        createValueBinding(value.toString());
      component.setValueBinding(_name, binding);
    }
    else
    {
      if (value == null)
        value = "test-" + _name;
  
      component.getAttributes().put(_name, value);
    }
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:50,代碼來源:TestScript.java

示例10: findRelativeComponent

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Find a component relative to another.
 * <p>
 * The relative ID must account for NamingContainers. If the component is already inside
 * of a naming container, you can use a single colon to start the search from the root, 
 * or multiple colons to move up through the NamingContainers - "::" will 
 * pop out of the current naming container, ":::" will pop out of two
 * naming containers, etc.
 * </p>
 * 
 * @param from the component to search relative to
 * @param scopedId the relative id path from the 'from' component to the
 *                 component to find
 * @return the component if found, null otherwise
 * @see org.apache.myfaces.trinidad.render.RenderUtils#getRelativeId
 * @see javax.faces.component.UIComponent#findComponent
 */
public static UIComponent findRelativeComponent(
  UIComponent from,
  String      scopedId)
{
  if (from == null)
      return null;
  UIComponent originalFrom = from;
  String originalRelativeId = scopedId;
  
  int idLength = scopedId.length();
  // Figure out how many colons
  int colonCount = 0;
  while (colonCount < idLength)
  {
    if (scopedId.charAt(colonCount) != NamingContainer.SEPARATOR_CHAR)
      break;
    colonCount++;
  }

  // colonCount == 0: fully relative
  // colonCount == 1: absolute (still normal findComponent syntax)
  // colonCount > 1: for each extra colon after 1, pop out of
  // the naming container (to the view root, if naming containers run out)
  if (colonCount > 1)
  {
    scopedId = scopedId.substring(colonCount);
    
    // if the component is not a NamingContainer, then we need to 
    // get the component's naming container and set this as the 'from'.
    // this way we'll pop out of the component's 
    // naming container if there is are multiple colons.
    if (!(from instanceof NamingContainer))
    {
      from = _getParentNamingContainerOrViewRoot(from);
    }
    
    // pop out of the naming containers if there are multiple colons
    for (int j = 1; j < colonCount; j++)
    {
      from = _getParentNamingContainerOrViewRoot(from);
    }
  }

  UIComponent found = from.findComponent(scopedId);
  if (found != null)
    return found;
  else
  {
    // try the old way for backward compatability as far as it differed,
    // which is only if the 'from' was not a NamingContainer.
    if (!(originalFrom instanceof NamingContainer))
      return _findRelativeComponentDeprecated(originalFrom, originalRelativeId);
    else
      return null;
  }
  
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:75,代碼來源:ComponentUtils.java

示例11: _findRelativeComponentDeprecated

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
  * Find a component relative to another.
  * This method is the same as the 'old' public findRelativeComponent.
 * This method is around so that the
 * new findRelativeComponent method is backward compatibility.
  * <p>
  * The relative ID must account for NamingContainers. If the component is already inside
  * of a naming container, you can use a single colon to start the search from the root, 
  * or multiple colons to move up through the NamingContainers - "::" will search from 
  * the parent naming container, ":::" will search from the grandparent 
  * naming container, etc.
  * </p>
  * 
  * @param from the component to search relative to
  * @param relativeId the relative path to the component to find
  * @return the component if found, null otherwise
  */
private static UIComponent _findRelativeComponentDeprecated(
  UIComponent from,
  String      relativeId)
{  
  UIComponent originalFrom = from;
  String originalRelativeId = relativeId;

  int idLength = relativeId.length();
  // Figure out how many colons
  int colonCount = 0;
  while (colonCount < idLength)
  {
    if (relativeId.charAt(colonCount) != NamingContainer.SEPARATOR_CHAR)
      break;
    colonCount++;
  }

  // colonCount == 0: fully relative
  // colonCount == 1: absolute (still normal findComponent syntax)
  // colonCount > 1: for each extra colon after 1, go up a naming container
  // (to the view root, if naming containers run out)
  if (colonCount > 1)
  {
    relativeId = relativeId.substring(colonCount);
    for (int j = 1; j < colonCount; j++)
    {
      while (from.getParent() != null)
      {
        from = from.getParent();
        if (from instanceof NamingContainer)
          break;
      }
    }
  }

  UIComponent found = from.findComponent(relativeId);
  if (found != null)
  {
    _LOG.warning("DEPRECATED_RELATIVE_ID_SYNTAX", 
      new Object[] {originalRelativeId, originalFrom});
  }
  return found;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:61,代碼來源:ComponentUtils.java

示例12: findComponent

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public UIComponent findComponent(String id)
{
  if (id == null)
    throw new NullPointerException();

  if ("".equals(id))
    throw new IllegalArgumentException();

  UIComponent from = this;
  // If it starts with the separator character, it's
  // an absolute path: start at the top
  if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR)
  {
    id = id.substring(1);
    while (from.getParent() != null)
      from = from.getParent();
  }
  // If it's a NamingContainer, start right here
  else if (this instanceof NamingContainer)
  {
    ;
  }
  // Otherwise, go up to look for NamingContainer (or the top)
  else
  {
    while (from.getParent() != null)
    {
      from = from.getParent();
      if (from instanceof NamingContainer)
        break;
    }
  }

  // Evaluate each part of the expression
  String searchId;
  int separatorIndex = id.indexOf(NamingContainer.SEPARATOR_CHAR);
  if (separatorIndex < 0)
    searchId = id;
  else
    searchId = id.substring(0, separatorIndex);

  if (searchId.equals(from.getId()))
  {
    // Don't need to look inside if we're already there
    ;
  }
  else
  {
    from = _findInsideOf(from, searchId);
  }

  // Final ID:  break, and return whatever we've found
  if (separatorIndex < 0)
  {
    return from;
  }
  // Just an intermediate step.  Make sure we're at a NamingContainer,
  // and then ask it to find the rest of the expression.
  else
  {
    if (from == null)
      return null;

    if (!(from instanceof NamingContainer))
      throw new IllegalArgumentException();
    return from.findComponent(id.substring(separatorIndex + 1));
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:70,代碼來源:UIXComponentBase.java


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