/** * @return true, if the attribute was written * @throws java.io.IOException */ public static boolean renderHTMLAttribute(ResponseWriter writer, String componentProperty, String attrName, Object value) throws IOException { if (!isDefaultAttributeValue(value)) { // render JSF "styleClass" attribute as "class" String htmlAttrName = attrName.equals(HTML.STYLE_CLASS_ATTR) ? HTML.CLASS_ATTR : attrName; writer.writeAttribute(htmlAttrName, value, componentProperty); return true; } return false; } /**
/** * @return true, if an attribute was written * @throws java.io.IOException */ public static boolean renderHTMLAttributes(ResponseWriter writer, UIComponent component, String[] attributes) throws IOException { boolean somethingDone = false; for (int i = 0, len = attributes.length; i < len; i++) { String attrName = attributes[i]; if (renderHTMLAttribute(writer, component, attrName, attrName)) { somethingDone = true; } } return somethingDone; } /**
HTML.renderHTMLAttributes(writer, component, HTML.INPUT_FILE_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
@Override protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { UILink link = (UILink) component; String url = link.getUrl(); writer.startElement(HTML.ANCHOR_ELEM, link); if (url != null && !link.isDisabled()) { writer.writeAttribute(HTML.HREF_ATTR, url, HTML.HREF_ATTR); } if (link.getId() != null) { writer.writeAttribute(HTML.ID_ATTR, link.getClientId(context), HTML.ID_ATTR); } HTML.renderHTMLAttributes(writer, link, HTML.ANCHOR_PASSTHROUGH_ATTRIBUTES); if (link.getValue() != null) { writer.writeText(link.getValue(), null); } }
@Override protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { UIButton button = (UIButton) component; writer.startElement(HTML.INPUT_ELEM, button); String onclick = getOnClick(button); if (!("").equals(onclick) && !button.isDisabled()) { writer.writeAttribute(HTML.ONCLICK_ATTR, onclick, HTML.ONCLICK_ATTR); } if (button.getId() != null) { writer.writeAttribute(HTML.ID_ATTR, button.getClientId(context), HTML.ID_ATTR); } HTML.renderHTMLAttributes(writer, button, HTML.BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONCLICK); if (button.getValue() != null) { writer.writeAttribute(HTML.VALUE_ATTR, button.getValue(), HTML.VALUE_ATTR); } if (button.isDisabled()) { writer.writeAttribute(HTML.DISABLED_ATTR, true, HTML.DISABLED_ATTR); } writer.writeAttribute(HTML.TYPE_ATTR, getType(button), HTML.TYPE_ATTR); if (button.getImage() != null) { writer.writeAttribute(HTML.SRC_ATTR, button.getImage(), HTML.SRC_ATTR); } }
/** * @return true, if the attribute was written * @throws java.io.IOException */ public static boolean renderHTMLAttribute(ResponseWriter writer, UIComponent component, String componentProperty, String htmlAttrName) throws IOException { Object value = component.getAttributes().get(componentProperty); return renderHTMLAttribute(writer, componentProperty, htmlAttrName, value); } /**
HTML.renderHTMLAttributes(writer, component, HTML.IMG_PASSTHROUGH_ATTRIBUTES); writer.endElement(HTML.IMG_ELEM);