예제 #1
0
  public static void renderPassThroughAttributesOptimized(
      FacesContext context,
      UIComponent component,
      Map<String, ComponentAttribute> knownAttributesMap)
      throws IOException {

    Object attributesThatAreSetObject = component.getAttributes().get(ATTRIBUTES_THAT_ARE_SET);
    if (attributesThatAreSetObject instanceof Collection<?>) {
      boolean disabled = isDisabled(component);
      Set<String> handledAttributes = new HashSet<String>(knownAttributesMap.size());

      Collection<?> attributesThatAreSet = (Collection<?>) attributesThatAreSetObject;
      for (Object attributeNameObject : attributesThatAreSet) {
        if (attributeNameObject == null) {
          continue;
        }

        String attributeName = attributeNameObject.toString();

        ComponentAttribute knownAttribute = knownAttributesMap.get(attributeName);
        if (knownAttribute != null) {
          handledAttributes.add(knownAttribute.getHtmlAttributeName());

          if (disabled && knownAttribute.getEventNames() != null) {
            continue;
          }

          renderAttributeAndBehaviors(context, component, knownAttribute);
        }
      }

      // render attributes that haven't been processed yet - there can be behaviors
      for (ComponentAttribute knownAttribute : knownAttributesMap.values()) {

        if (handledAttributes.contains(knownAttribute.getHtmlAttributeName())) {
          continue;
        }

        renderAttributeAndBehaviors(context, component, knownAttribute);
      }
    } else {
      // switch to unoptimized mode
      renderPassThroughAttributes(context, component, knownAttributesMap);
    }
  }
예제 #2
0
 public static void renderPassThroughAttributes(
     FacesContext context, UIComponent component, Collection<ComponentAttribute> attributes)
     throws IOException {
   boolean disabled = isDisabled(component);
   for (ComponentAttribute knownAttribute : attributes) {
     if (!disabled || knownAttribute.getEventNames().length == 0) {
       renderAttributeAndBehaviors(context, component, knownAttribute);
     }
   }
 }