public static String prefixAttribute(final String attrName, boolean isXhtml) { if (isXhtml) { if (Arrays.binarySearch(XHTML_PREFIX_ATTRIBUTES, attrName) > -1) { return XHTML_ATTR_PREFIX + attrName; } else { return attrName; } } else { return attrName; } }
private static void renderPassThruAttributesOptimized( FacesContext context, ResponseWriter writer, UIComponent component, Attribute[] knownAttributes, List<String> setAttributes, Map<String, List<ClientBehavior>> behaviors) throws IOException { String behaviorEventName = getSingleBehaviorEventName(behaviors); boolean renderedBehavior = false; Collections.sort(setAttributes); boolean isXhtml = XHTML_CONTENT_TYPE.equals(writer.getContentType()); Map<String, Object> attrMap = component.getAttributes(); for (String name : setAttributes) { int index = Arrays.binarySearch(knownAttributes, Attribute.attr(name)); if (index >= 0) { Object value = attrMap.get(name); if (value != null && shouldRenderAttribute(value)) { Attribute attr = knownAttributes[index]; if (isBehaviorEventAttribute(attr, behaviorEventName)) { renderHandler(context, component, null, name, value, behaviorEventName); renderedBehavior = true; } else { writer.writeAttribute(prefixAttribute(name, isXhtml), value, name); } } } } if ((behaviorEventName != null) && !renderedBehavior) { for (int i = 0; i < knownAttributes.length; i++) { Attribute attr = knownAttributes[i]; String[] events = attr.getEvents(); if ((events != null) && (events.length > 0) && (behaviorEventName.equals(events[0]))) { renderHandler(context, component, null, attr.getName(), null, behaviorEventName); } } } }