/** * Renders the start of a table and applies the value of <code>styleClass</code> if available and * renders any pass through attributes that may be specified. * * @param context the <code>FacesContext</code> for the current request * @param table the table that's being rendered * @param writer the current writer * @param passThroughAttributes pass-through attributes that the component supports * @throws IOException if content cannot be written */ protected void renderTableStart( FacesContext context, UIComponent table, ResponseWriter writer, String[] passThroughAttributes) throws IOException { writer.startElement("table", table); writeIdAttributeIfNecessary(context, writer, table); String styleClass = (String) table.getAttributes().get("styleClass"); if (styleClass != null) { writer.writeAttribute("class", styleClass, "styleClass"); } RenderKitUtils.renderPassThruAttributes(writer, table, passThroughAttributes); writer.writeText("\n", table, null); }
@Override protected void getEndTextToRender( FacesContext context, UIComponent component, String currentValue) throws IOException { ResponseWriter writer = context.getResponseWriter(); assert (writer != null); String redisplay = String.valueOf(component.getAttributes().get("redisplay")); if (redisplay == null || !redisplay.equals("true")) { currentValue = ""; } writer.startElement("input", component); writeIdAttributeIfNecessary(context, writer, component); writer.writeAttribute("type", "password", "type"); writer.writeAttribute("name", component.getClientId(context), "clientId"); String autoComplete = (String) component.getAttributes().get("autocomplete"); if (autoComplete != null) { // only output the autocomplete attribute if the value // is 'off' since its lack of presence will be interpreted // as 'on' by the browser if ("off".equals(autoComplete)) { writer.writeAttribute("autocomplete", "off", "autocomplete"); } } // render default text specified if (currentValue != null) { writer.writeAttribute("value", currentValue, "value"); } RenderKitUtils.renderPassThruAttributes( context, writer, component, ATTRIBUTES, getNonOnChangeBehaviors(component)); RenderKitUtils.renderXHTMLStyleBooleanAttributes(writer, component); RenderKitUtils.renderOnchange(context, component, false); String styleClass; if (null != (styleClass = (String) component.getAttributes().get("styleClass"))) { writer.writeAttribute("class", styleClass, "styleClass"); } writer.endElement("input"); }
@Override protected void getEndTextToRender( FacesContext context, UIComponent component, String currentValue) throws IOException { ResponseWriter writer = context.getResponseWriter(); assert (writer != null); boolean shouldWriteIdAttribute = false; boolean isOutput = false; String style = (String) component.getAttributes().get("style"); String styleClass = (String) component.getAttributes().get("styleClass"); String dir = (String) component.getAttributes().get("dir"); String lang = (String) component.getAttributes().get("lang"); String title = (String) component.getAttributes().get("title"); Map<String, Object> passthroughAttributes = component.getPassThroughAttributes(false); boolean hasPassthroughAttributes = null != passthroughAttributes && !passthroughAttributes.isEmpty(); if (component instanceof UIInput) { writer.startElement("input", component); writeIdAttributeIfNecessary(context, writer, component); if (component instanceof HtmlInputFile) { writer.writeAttribute("type", "file", null); } else { writer.writeAttribute("type", "text", null); } writer.writeAttribute("name", (component.getClientId(context)), "clientId"); // only output the autocomplete attribute if the value // is 'off' since its lack of presence will be interpreted // as 'on' by the browser if ("off".equals(component.getAttributes().get("autocomplete"))) { writer.writeAttribute("autocomplete", "off", "autocomplete"); } // render default text specified if (currentValue != null) { writer.writeAttribute("value", currentValue, "value"); } if (null != styleClass) { writer.writeAttribute("class", styleClass, "styleClass"); } // style is rendered as a passthur attribute RenderKitUtils.renderPassThruAttributes( context, writer, component, INPUT_ATTRIBUTES, getNonOnChangeBehaviors(component)); RenderKitUtils.renderXHTMLStyleBooleanAttributes(writer, component); RenderKitUtils.renderOnchange(context, component, false); writer.endElement("input"); } else if (isOutput = (component instanceof UIOutput)) { if (styleClass != null || style != null || dir != null || lang != null || title != null || hasPassthroughAttributes || (shouldWriteIdAttribute = shouldWriteIdAttribute(component))) { writer.startElement("span", component); writeIdAttributeIfNecessary(context, writer, component); if (null != styleClass) { writer.writeAttribute("class", styleClass, "styleClass"); } // style is rendered as a passthru attribute RenderKitUtils.renderPassThruAttributes(context, writer, component, OUTPUT_ATTRIBUTES); } if (currentValue != null) { Object val = component.getAttributes().get("escape"); if ((val != null) && Boolean.valueOf(val.toString())) { writer.writeText(currentValue, component, "value"); } else { writer.write(currentValue); } } } if (isOutput && (styleClass != null || style != null || dir != null || lang != null || title != null || hasPassthroughAttributes || (shouldWriteIdAttribute))) { writer.endElement("span"); } }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { rendererParamsNotNull(context, component); if (!shouldEncode(component)) return; boolean mustRender = shouldWriteIdAttribute(component); UIMessages messages = (UIMessages) component; ResponseWriter writer = context.getResponseWriter(); assert (writer != null); String clientId = ((UIMessages) component).getFor(); if (clientId == null) if (messages.isGlobalOnly()) clientId = ""; Iterator messageIter = getMessageIter(context, clientId, component); assert (messageIter != null); if (!messageIter.hasNext()) { if (mustRender) { if ("javax_faces_developmentstage_messages".equals(component.getId())) { return; } writer.startElement("div", component); writeIdAttributeIfNecessary(context, writer, component); writer.endElement("div"); } return; } writeIdAttributeIfNecessary(context, writer, component); // style is rendered as a passthru attribute RenderKitUtils.renderPassThruAttributes(context, writer, component, ATTRIBUTES); Map<Severity, List<FacesMessage>> msgs = new HashMap<Severity, List<FacesMessage>>(); msgs.put(FacesMessage.SEVERITY_INFO, new ArrayList<FacesMessage>()); // Bootstrap info msgs.put(FacesMessage.SEVERITY_WARN, new ArrayList<FacesMessage>()); // Bootstrap warning msgs.put(FacesMessage.SEVERITY_ERROR, new ArrayList<FacesMessage>()); // Bootstrap error msgs.put(FacesMessage.SEVERITY_FATAL, new ArrayList<FacesMessage>()); // Bootstrap error while (messageIter.hasNext()) { FacesMessage curMessage = (FacesMessage) messageIter.next(); if (curMessage.isRendered() && !messages.isRedisplay()) { continue; } msgs.get(curMessage.getSeverity()).add(curMessage); } List<FacesMessage> severityMessages = msgs.get(FacesMessage.SEVERITY_FATAL); if (severityMessages.size() > 0) { encodeLoadingInfo( context, component, messages, FacesMessage.SEVERITY_FATAL, severityMessages); } severityMessages = msgs.get(FacesMessage.SEVERITY_ERROR); if (severityMessages.size() > 0) { encodeLoadingInfo( context, component, messages, FacesMessage.SEVERITY_ERROR, severityMessages); } severityMessages = msgs.get(FacesMessage.SEVERITY_WARN); if (severityMessages.size() > 0) { encodeLoadingInfo(context, component, messages, FacesMessage.SEVERITY_WARN, severityMessages); } severityMessages = msgs.get(FacesMessage.SEVERITY_INFO); if (severityMessages.size() > 0) { encodeLoadingInfo(context, component, messages, FacesMessage.SEVERITY_INFO, severityMessages); } }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { // Hoy por hoy se tiene que hacer de esta manera rendererParamsNotNull(context, component); if (!shouldEncode(component)) { return; } // Which button type (SUBMIT, RESET, or BUTTON) should we generate? String type = getButtonType(component); ResponseWriter writer = context.getResponseWriter(); assert (writer != null); String label = ""; Object value = ((UICommand) component).getValue(); if (value != null) { label = value.toString(); } /* * If we have any parameters and the button type is submit or button, * then render Javascript to use later. * RELEASE_PENDING this logic is slightly wrong - we should buffer the user onclick, and use it later. * Leaving it for when we decide how to do script injection. */ Collection<ClientBehaviorContext.Parameter> params = getBehaviorParameters(component); if (!params.isEmpty() && (type.equals("submit") || type.equals("button"))) { RenderKitUtils.renderJsfJs(context); } String imageSrc = (String) component.getAttributes().get("image"); writer.startElement("input", component); writeIdAttributeIfNecessary(context, writer, component); String clientId = component.getClientId(context); if (imageSrc != null) { writer.writeAttribute("type", "image", "type"); writer.writeURIAttribute( "src", RenderKitUtils.getImageSource(context, component, "image"), "image"); writer.writeAttribute("name", clientId, "clientId"); } else { writer.writeAttribute("type", type, "type"); writer.writeAttribute("name", clientId, "clientId"); writer.writeAttribute("value", label, "value"); } RenderKitUtils.renderPassThruAttributes( context, writer, component, ATTRIBUTES, getNonOnClickBehaviors(component)); RenderKitUtils.renderXHTMLStyleBooleanAttributes(writer, component); String styleClass = (String) component.getAttributes().get("styleClass"); if (styleClass != null && styleClass.length() > 0) { writer.writeAttribute("class", styleClass, "styleClass"); } // EasyTech // Data-* for (String key : component.getAttributes().keySet()) { if (key.startsWith("data-")) writer.writeAttribute(key, component.getAttributes().get(key), key); } RenderKitUtils.renderOnclick(context, component, params, null, false); writer.endElement("input"); }