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


Java UIComponent.getId方法代碼示例

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


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

示例1: startElement

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public void startElement(String name, UIComponent component) throws IOException
 {
   if ((component != null) && (_lastComponentStarted != component))
   {
     String componentAsString = component.getFamily();
     String id = component.getId();
     if (id != null)
     {
       componentAsString = componentAsString + "[\"" + id + "\"]";
     }

     writeComment("Start: " + componentAsString);

     _lastComponentStarted = component;
   }

   super.startElement(name, component);
   _inElement = true;
   _elementStack.push(name);
   _attributes.clear();
 }
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:DebugResponseWriter.java

示例2: 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

示例3: shouldRenderId

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Returns true if the component should render an ID.  Components
 * that deliver events should always return "true".
 */
// TODO Is this a bottleneck?  If so, optimize!
protected boolean shouldRenderId(
  FacesContext context,
  UIComponent component)
{
  String id = component.getId();

  // Otherwise, if ID isn't set, don't bother
  if (id == null)
    return false;

  // ... or if the ID was generated, don't bother
  if (id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    return false;

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

示例4: getSectionId

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Tries to get the id of a parent section if existing.
 * 
 * @param uiComponent
 *            the component to check the parents for
 * @return the id of the section if found or <code>null</code>
 */
private String getSectionId(UIComponent uiComponent) {
    UIComponent parent = uiComponent.getParent();
    if (parent instanceof UIViewRoot) {
        return null;
    }
    if (parent instanceof UITogglePanel) {
        return parent.getId();
    }
    return getSectionId(parent);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:18,代碼來源:MessageListener.java

示例5: onComponentPopulated

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
@Override
public void onComponentPopulated(FaceletContext context,
                                   UIComponent component,
                                   UIComponent parent)
{
  assert (_markInitialState != null);

  if ((component instanceof UIXComponent) &&
      (_markInitialState == Boolean.TRUE))
  {
    if (component.getId() == null)
      component.setId(context.generateUniqueId(UIViewRoot.UNIQUE_ID_PREFIX));
    
    PhaseId phase = context.getFacesContext().getCurrentPhaseId();
    
    // In jsf2 markInitialState will be called by the framework during restore view, 
    // and in fact the framework should always be the one
    // calling markInitialState, but it doesn't always do that in render response, see
    // http://java.net/jira/browse/JAVASERVERFACES-2285
    // Also don't call markInitialState unless initialStateMarked returns false, otherwise
    // any deltas previously saved may get blown away.
    if (PhaseId.RENDER_RESPONSE.equals(phase) && !component.initialStateMarked())
    {
      component.markInitialState();
    }
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:28,代碼來源:TrinidadComponentHandler.java

示例6: Structure

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Create the structure of an existing component.
 */
public Structure(UIComponent component)
{
  _class = component.getClass().getName();
  _id = component.getId();
  _facets = _getFacets(component);
  _children = _getChildren(component);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:11,代碼來源:Structure.java

示例7: addRelocatedFacet

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Indicate that a facet was moved. The region component must keep track
 * of all facets that were moved so that they may be restored before the
 * jsf jsp tag framework notices. If the jsf jsp tag framework notices
 * that the facets are missing, it will recreate them, and that is undesireable
 * as that will break the "binding" attribute support
 * (on the facet) and will have performance consequences.
 * @param region the component that the facet was moved from.
 * @param facet the facet that was moved.
 * @param component the component that the facet was moved to.
 */
@SuppressWarnings("unchecked")
public static void addRelocatedFacet(
  UIComponent region,
  String facet,
  UIComponent component)
{
  Map<String, RelocatedFacet> map = 
    (Map<String, RelocatedFacet>) region.getAttributes().get(_RELOCATED_FACETS_ATTRIBUTE);
  if (map == null)
  {
    map = new HashMap<String, RelocatedFacet>(3);
    region.getAttributes().put(_RELOCATED_FACETS_ATTRIBUTE, map);
  }

  // compute the ID to retrieve this relocated facet later.
  // this is because we don't always have the relocated facet instance
  // For example, after Serialization, the relocated facet instance is lost:
  StringBuffer findId = new StringBuffer(component.getId());
  for(UIComponent c = component.getParent(); c!=region; c = c.getParent())
  {
    if (c instanceof NamingContainer)
    {
      findId.insert(0, NamingContainer.SEPARATOR_CHAR);
      findId.insert(0, c.getId());
    }
  }

  map.put(facet, new RelocatedFacet(component, findId.toString()));
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:41,代碼來源:ComponentRefTag.java

示例8: _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

示例9: calculateScopedId

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
protected static String calculateScopedId(
  UIComponent component,
  String      componentId)
{
  if (componentId == null)
    throw new IllegalStateException("Can't create a ComponentReference for component " +
                                    component +
                                    " no id");    
  int scopedIdLength = componentId.length();

  List<String> scopedIdList = new ArrayList<String>();
 
  // determine how many characters we need to store the scopedId.  We skip the component itself,
  // because we have already accounted for its id
  UIComponent currAncestor = component.getParent();
  
  while (currAncestor != null)
  {
    // add the sizes of all of the NamingContainer ancestors, plus 1 for each NamingContainer separator
    if (currAncestor instanceof NamingContainer)
    {
      String currId = currAncestor.getId();
      scopedIdLength += currId.length() + 1;
    
      // add the NamingContainer to the list of NamingContainers
      scopedIdList.add(currId);
    }
    
    currAncestor = currAncestor.getParent();
  }
  
  // now append all of the NamingContaintes
  return _createScopedId(scopedIdLength, scopedIdList, componentId);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:35,代碼來源:ComponentReference.java

示例10: getScopedId

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
protected String getScopedId()
{
  String scopedId = _scopedId;
  
  // we have no scopedId, so calculate the scopedId and finish initializing
  // the DeferredComponentReference
  if (scopedId == null)
  {
    UIComponent component = _component;
    
    // need to check that component isn't null because of possible race condition if this
    // method is called from different threads.  In that case, scopedId will have been filled
    // in, so we can return it
    if (component != null)
    {
      String componentId = component.getId();
                
      scopedId = calculateScopedId(component, componentId);
      _scopedId = scopedId;
      _componentId = componentId;
      
      // store away our component path while we can efficiently calculate it
      setComponentPath(calculateComponentPath(component));
      
      _component = null;
    }
    else
    {
      scopedId = _scopedId;
    }
  }
  
  return scopedId;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:35,代碼來源:ComponentReference.java

示例11: _getScopedIdForComponentImpl

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Returns scoped id for a component
 * @param targetComponent The component for which the scoped id needs to be
 * determined.
 * @param baseComponent The component relative to which the scoped id for the
 * targetComponent needs to be determined.
 * @param isLogical true if a logical scoped id (the id in the context of the document where targetComponent was defined)
 * should be returned, false otherwise
 * @return The scoped id for target component. Returns null if the supplied
 * targetComponent was null or did not have an id.
 */
private static String _getScopedIdForComponentImpl(
  UIComponent targetComponent,
  UIComponent baseComponent,
  boolean isLogical)
{
  String targetComponentId = targetComponent.getId();
  
  if (targetComponent == null || 
      targetComponentId == null ||
      targetComponentId.length() == 0)
    return null;
  
  // Optimize when both arguments are the same
  if (targetComponent.equals(baseComponent))
    return targetComponentId;

  StringBuilder builder = new StringBuilder(100);
  
  // Add a leading ':' if the baseComponent is the view root
  if (baseComponent instanceof UIViewRoot)
    builder.append(NamingContainer.SEPARATOR_CHAR);

  _buildScopedId(targetComponent, baseComponent, builder, isLogical);
  
  return builder.toString();
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:38,代碼來源:ComponentUtils.java

示例12: _clearCachedClientIds

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * Default implementation of clearing the cached client ids
 */
private static void _clearCachedClientIds(UIComponent component)
{
  // clear this component
  String id = component.getId();
  component.setId(id);

  // clear the children
  Iterator<UIComponent> allChildren = component.getFacetsAndChildren();

  while (allChildren.hasNext())
  {
    clearCachedClientIds(allChildren.next());
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:18,代碼來源:UIXComponent.java

示例13: _restoreStampState

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
   * Restores the state of all the stamps of this component.
   * This method should be called after the currency of this component
   * changes. This method gets all the stamps using {@link #getStamps} and
   * restores their states by calling
   * {@link #restoreStampState}.
   */
  private void _restoreStampState()
  {
    StampState stampState = _getStampState();
    Map<String, String> idToIndexMap = _getIdToIndexMap();
    FacesContext context = getFacesContext();
    Object currencyObj = getRowKey();
    for(UIComponent stamp : getStamps())
    {
//      String stampId = stamp.getId();
      // TODO
      // temporarily use position. later we need to use ID's to access
      // stamp state everywhere, and special case NamingContainers:
      String compId = stamp.getId();
      String stampId = idToIndexMap.get(compId);
      Object state = stampState.get(currencyObj, stampId);
      if (state == null)
      {
        Object iniStateObj = _getCurrencyKeyForInitialStampState();
        state = stampState.get(iniStateObj, stampId);
        /*
        if (state==null)
        {
          _LOG.severe("NO_INITIAL_STAMP_STATE", new Object[]{currencyObj,iniStateObj,stampId});
          continue;
        }*/
      }
      restoreStampState(context, stamp, state);
    }
  }
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:37,代碼來源:UIXCollection.java

示例14: getName

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
 * <p>
 * Return the calculated name for the hidden input field.</p>
 *
 * @param context Context for the current request
 * @param component Component we are rendering
 */
private String getName(FacesContext context, UIComponent component) {
    while (component != null) {
        if (component instanceof MapComponent) {
            return (component.getId() + "_current");
        }

        component = component.getParent();
    }

    throw new IllegalArgumentException();
}
 
開發者ID:wwu-pi,項目名稱:tap17-muggl-javaee,代碼行數:19,代碼來源:AreaRenderer.java

示例15: _saveStampState

import javax.faces.component.UIComponent; //導入方法依賴的package包/類
/**
   * Saves the state of all the stamps of this component.
   * This method should be called before the rowData of this component
   * changes. This method gets all the stamps using {@link #getStamps} and
   * saves their states by calling {@link #saveStampState}.
   */
  private void _saveStampState()
  {
    // Never read and created by _getStampState
    //InternalState iState = _getInternalState(true);

    StampState stampState = _getStampState();
    Map<String, String> idToIndexMap = _getIdToIndexMap();
    FacesContext context = getFacesContext();
    Object currencyObj = getRowKey();

    // Note: even though the currencyObj may be null, we still need to save the state. The reason
    // is that the code does not clear out the state when it is saved, instead, the un-stamped
    // state is saved. Once the row key is set back to null, this un-stamped state is restored
    // onto the children components. This restoration allows editable value holders, show detail
    // items and nested UIXCollections to clear their state.
    // For nested UIXCollections, this un-stamped state is required to set the nested collection's
    // _state (internal state containing the stamp state) to null when not on a row key. Without
    // that call, the nested UIXCollection components would end up sharing the same stamp state
    // across parent rows.

    for (UIComponent stamp : getStamps())
    {
      Object state = saveStampState(context, stamp);
//      String stampId = stamp.getId();
      // TODO
      // temporarily use position. later we need to use ID's to access
      // stamp state everywhere, and special case NamingContainers:
      String compId = stamp.getId();
      String stampId = idToIndexMap.get(compId);
      if (stampId == null)
      {
        stampId = String.valueOf(idToIndexMap.size());
        idToIndexMap.put(compId, stampId);
      }
      stampState.put(currencyObj, stampId, state);
      if (_LOG.isFinest())
        _LOG.finest("saving stamp state for currencyObject:"+currencyObj+
          " and stampId:"+stampId);
    }
  }
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:47,代碼來源:UIXCollection.java


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