Java Code Examples for javax.faces.component.UIComponent#encodeAll()
The following examples show how to use
javax.faces.component.UIComponent#encodeAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThumbnailRenderer.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
/** * This methods generates the HTML code of the current b:thumbnail. * <code>encodeBegin</code> generates the start of the component. After the, the JSF framework calls <code>encodeChildren()</code> * to generate the HTML code between the beginning and the end of the component. For instance, in the case of a panel component * the content of the panel is generated by <code>encodeChildren()</code>. After that, <code>encodeEnd()</code> is called * to generate the rest of the HTML code. * @param context the FacesContext. * @param component the current b:thumbnail. * @throws IOException thrown if something goes wrong when writing the HTML code. */ @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } Thumbnail thumbnail = (Thumbnail) component; ResponseWriter rw = context.getResponseWriter(); UIComponent capt; capt = thumbnail.getFacet("caption"); if (capt != null ) { rw.startElement("div", thumbnail); rw.writeAttribute("class", "caption", "class"); capt.encodeAll(context); rw.endElement("div"); } rw.endElement("div"); Tooltip.activateTooltips(context, thumbnail); endResponsiveWrapper(component, rw); }
Example 2
Source File: SelectMultiMenuRenderer.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
/** * Renders components added seamlessly behind the input field. * * @param context * the FacesContext * @param rw * the response writer * @param appendingAddOnFacet * optional facet behind the field. Can be null. * @param hasAppendingAddOn * optional facet in front of the field. Can be null. * @throws IOException * may be thrown by the response writer */ protected void addAppendingAddOnToInputGroup(FacesContext context, ResponseWriter rw, UIComponent appendingAddOnFacet, boolean hasAppendingAddOn, SelectMultiMenu menu) throws IOException { if (hasAppendingAddOn) { if (appendingAddOnFacet.getClass().getName().endsWith("Button") || (appendingAddOnFacet.getChildCount() > 0 && appendingAddOnFacet.getChildren().get(0).getClass().getName().endsWith("Button"))) { rw.startElement("div", menu); rw.writeAttribute("class", "input-group-btn", "class"); appendingAddOnFacet.encodeAll(context); rw.endElement("div"); } else { rw.startElement("span", menu); rw.writeAttribute("class", "input-group-addon", "class"); appendingAddOnFacet.encodeAll(context); rw.endElement("span"); } } }
Example 3
Source File: BreadcrumbsRenderer.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
/** * This methods generates the HTML code of the current b:breadcrumbs. <code>encodeBegin</code> generates the * start of the component. After the, the JSF framework calls <code>encodeChildren()</code> to generate the HTML * code between the beginning and the end of the component. For instance, in the case of a panel component the * content of the panel is generated by <code>encodeChildren()</code>. After that, <code>encodeEnd()</code> is * called to generate the rest of the HTML code. * * @param context the FacesContext. * @param component the current b:breadcrumbs. * @throws IOException thrown if something goes wrong when writing the HTML code. */ @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } ResponseWriter rw = context.getResponseWriter(); // End point / current page UIComponent end = component.getFacet("end"); if (end != null) { rw.startElement("li", component); end.encodeAll(context); rw.endElement("li"); } rw.endElement("ol"); Tooltip.activateTooltips(context, component); }
Example 4
Source File: R.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Add the correct class * * @param parent * @param comp * @param ctx * @param rw * @throws IOException */ private static void decorateComponent(UIComponent parent, UIComponent comp, FacesContext ctx, ResponseWriter rw) throws IOException { if (comp instanceof Icon) ((Icon) comp).setAddon(true); // modifies the id of the icon String classToApply = "input-group-addon"; if (comp.getClass().getName().endsWith("Button") || comp.getChildCount() > 0) classToApply = "input-group-btn"; if (comp instanceof HtmlOutputText) { HtmlOutputText out = (HtmlOutputText)comp; String sc = out.getStyleClass(); if (sc == null) sc = classToApply; else sc = sc + " " + classToApply; out.setStyleClass(sc); comp.encodeAll(ctx); } else { rw.startElement("span", parent); rw.writeAttribute("class", classToApply, "class"); comp.encodeAll(ctx); rw.endElement("span"); } }
Example 5
Source File: TabViewRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Generate the clickable entity of the tab. * * @param writer * the response writer * @param tab * the tab to be rendered. * @throws IOException * only thrown if something's wrong with the response writer */ private static void encodeTabAnchorTag(FacesContext context, ResponseWriter writer, Tab tab, String hiddenInputFieldID, int tabindex, boolean disabled) throws IOException { writer.startElement("a", tab); writer.writeAttribute("id", tab.getClientId().replace(":", "_") + "_tab", "id"); writer.writeAttribute("role", "tab", "role"); if (tab.isDisabled() || disabled) { writer.writeAttribute("onclick", "event.preventDefault(); return false;", null); } else { writer.writeAttribute("data-toggle", "tab", "data-toggle"); writer.writeAttribute("href", "#" + tab.getClientId().replace(":", "_") + "_pane", "href"); String onclick = "document.getElementById('" + hiddenInputFieldID + "').value='" + String.valueOf(tabindex) + "';"; AJAXRenderer.generateBootsFacesAJAXAndJavaScript(context, tab, writer, "click", onclick, false, true); } R.encodeHTML4DHTMLAttrs(writer, tab.getAttributes(), new String[] { "style", "tabindex" }); UIComponent iconFacet = tab.getFacet("anchor"); if (null != iconFacet) { iconFacet.encodeAll(FacesContext.getCurrentInstance()); if (null != tab.getTitle()) { writer.writeText(" " + tab.getTitle(), null); } } else { writer.writeText(tab.getTitle(), null); } writer.endElement("a"); }
Example 6
Source File: DataTableRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
private void generateMultiColumnSearchRow(FacesContext context, DataTable dataTable, ResponseWriter rw) throws IOException { rw.startElement("tr", dataTable); List<UIComponent> columns = dataTable.getChildren(); for (UIComponent column : columns) { if (!column.isRendered()) { continue; } rw.startElement("td", dataTable); Object footerStyle = column.getAttributes().get("footerStyle"); if (footerStyle != null) { rw.writeAttribute("style", footerStyle, null); } Object searchable = column.getAttributes().get("searchable"); if (searchable == null || ((searchable instanceof Boolean) && ((Boolean) searchable).equals(Boolean.TRUE)) || ((searchable instanceof String) && ((String) searchable).equalsIgnoreCase("true"))) { Object footerStyleClass = column.getAttributes().get("footerStyleClass"); if (footerStyleClass != null) { rw.writeAttribute("class", "bf-multisearch " + footerStyleClass, null); } else { rw.writeAttribute("class", "bf-multisearch", null); } if (column.getFacet("header") != null) { UIComponent facet = column.getFacet("header"); facet.encodeAll(context); } else if (column.getAttributes().get("label") != null) { rw.writeText(column.getAttributes().get("label"), null); } } rw.endElement("td"); } rw.endElement("tr"); }
Example 7
Source File: ModalRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * This methods generates the HTML code of the current b:modal. * <code>encodeBegin</code> generates the start of the component. After the, * the JSF framework calls <code>encodeChildren()</code> to generate the * HTML code between the beginning and the end of the component. For * instance, in the case of a panel component the content of the panel is * generated by <code>encodeChildren()</code>. After that, * <code>encodeEnd()</code> is called to generate the rest of the HTML code. * * @param context * the FacesContext. * @param component * the current b:modal. * @throws IOException * thrown if something goes wrong when writing the HTML code. */ @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } ResponseWriter rw = context.getResponseWriter(); rw.endElement("div"); // modal-body String cid=component.getClientId(context); UIComponent foot = component.getFacet("footer"); if (foot != null) { rw.startElement("div", component); // modal-footer rw.writeAttribute("id", cid+"_footer", "id"); rw.writeAttribute("class", "modal-footer", "class"); foot.encodeAll(context); rw.endElement("div"); // modal-footer } rw.endElement("div"); // modal-content rw.endElement("div"); // modal-dialog rw.endElement("div"); // modal initModal(rw, cid); }
Example 8
Source File: SelectMultiMenuRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Renders components added seamlessly in front of the input field. * * @param context * the FacesContext * @param rw * the response writer * @param prependingAddOnFacet * @param hasPrependingAddOn * @throws IOException * may be thrown by the response writer */ protected void addPrependingAddOnToInputGroup(FacesContext context, ResponseWriter rw, UIComponent prependingAddOnFacet, boolean hasPrependingAddOn, SelectMultiMenu menu) throws IOException { if (hasPrependingAddOn) { if (prependingAddOnFacet.getClass().getName().endsWith("Button") || (prependingAddOnFacet.getChildCount() > 0 && prependingAddOnFacet.getChildren().get(0).getClass().getName().endsWith("Button"))) { rw.startElement("div", menu); rw.writeAttribute("class", "input-group-btn", "class"); prependingAddOnFacet.encodeAll(context); rw.endElement("div"); } else if (prependingAddOnFacet instanceof HtmlOutputText) { HtmlOutputText out = (HtmlOutputText) prependingAddOnFacet; String sc = out.getStyleClass(); if (sc == null) sc = "input-group-addon"; else sc = sc + " " + "input-group-addon"; out.setStyleClass(sc); prependingAddOnFacet.encodeAll(context); } else { rw.startElement("span", menu); rw.writeAttribute("class", "input-group-addon", "class"); prependingAddOnFacet.encodeAll(context); rw.endElement("span"); } } }
Example 9
Source File: BreadcrumbsRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * This methods generates the HTML code of the current b:breadcrumbs. <code>encodeBegin</code> generates the * start of the component. After the, the JSF framework calls <code>encodeChildren()</code> to generate the HTML * code between the beginning and the end of the component. For instance, in the case of a panel component the * content of the panel is generated by <code>encodeChildren()</code>. After that, <code>encodeEnd()</code> is * called to generate the rest of the HTML code. * * @param context the FacesContext. * @param component the current b:breadcrumbs. * @throws IOException thrown if something goes wrong when writing the HTML code. */ @Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } Breadcrumbs breadcrumbs = (Breadcrumbs) component; ResponseWriter rw = context.getResponseWriter(); String clientId = breadcrumbs.getClientId(); rw.startElement("ol", breadcrumbs); rw.writeAttribute("id", clientId, "id"); String style = breadcrumbs.getStyle(); if (null != style && style.length() > 0) { rw.writeAttribute("style", style, "style"); } Tooltip.generateTooltip(context, breadcrumbs, rw); String styleClass = breadcrumbs.getStyleClass(); if (null == styleClass) { styleClass = ""; } rw.writeAttribute("class", "breadcrumb ".concat(styleClass), "class"); // Root node UIComponent root = component.getFacet("root"); if (root != null) { rw.startElement("li", component); root.encodeAll(context); rw.endElement("li"); } }
Example 10
Source File: PanelRenderer.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
/** * This methods generates the HTML code of the current b:panel. * <code>encodeBegin</code> generates the start of the component. After the, * the JSF framework calls <code>encodeChildren()</code> to generate the * HTML code between the beginning and the end of the component. For * instance, in the case of a panel component the content of the panel is * generated by <code>encodeChildren()</code>. After that, * <code>encodeEnd()</code> is called to generate the rest of the HTML code. * * @param context * the FacesContext. * @param component * the current b:panel. * @throws IOException * thrown if something goes wrong when writing the HTML code. */ @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } Panel panel = (Panel) component; ResponseWriter rw = context.getResponseWriter(); if (panel.isContentDisabled()) { rw.endElement("fieldset"); } String clientId = panel.getClientId(); rw.endElement("div"); // panel-body UIComponent foot = panel.getFacet("footer"); if (foot != null) { rw.startElement("div", panel); // modal-footer rw.writeAttribute("class", "panel-footer", "class"); foot.encodeAll(context); rw.endElement("div"); // panel-footer } rw.endElement("div"); rw.endElement("div"); // panel-body boolean isCollapsible = panel.isCollapsible(); String accordionParent = panel.getAccordionParent(); String responsiveCSS = Responsive.getResponsiveStyleClass(panel, false).trim(); boolean isResponsive = responsiveCSS.length() > 0; if ((isCollapsible||isResponsive) && null == accordionParent) { rw.endElement("div"); if (isCollapsible) { String jQueryClientID = clientId.replace(":", "_"); rw.startElement("input", panel); rw.writeAttribute("type", "hidden", null); String hiddenInputFieldID = jQueryClientID + "_collapsed"; rw.writeAttribute("name", hiddenInputFieldID, "name"); rw.writeAttribute("id", hiddenInputFieldID, "id"); rw.writeAttribute("value", String.valueOf(panel.isCollapsed()), "value"); rw.endElement("input"); Map<String, String> eventHandlers = new HashMap<String, String>(); eventHandlers.put("expand", "document.getElementById('" + hiddenInputFieldID + "').value='false';"); eventHandlers.put("collapse", "document.getElementById('" + hiddenInputFieldID + "').value='true';"); eventHandlers.put("expanded","if(typeof PrimeFaces != 'undefined'){PrimeFaces.invokeDeferredRenders('" + clientId + "_body');}"); new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForJQuery(context, component, rw, "#"+jQueryClientID+"_content", eventHandlers); } } Tooltip.activateTooltips(context, panel); }
Example 11
Source File: PanelGridRenderer.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
/** Renders the grid component and its children. */ @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } PanelGrid panelGrid = (PanelGrid) component; ResponseWriter writer = context.getResponseWriter(); boolean idHasBeenRendered=false; String responsiveStyle= Responsive.getResponsiveStyleClass(panelGrid, false); if (null != responsiveStyle) { writer.startElement("div", panelGrid); writer.writeAttribute("class", responsiveStyle.trim(), null); String clientId = panelGrid.getClientId(); writer.writeAttribute("id", clientId, "id"); idHasBeenRendered=true; } generateContainerStart(writer, panelGrid, idHasBeenRendered); beginDisabledFieldset(panelGrid, writer); int[] columns = getColSpanArray(panelGrid); String[] columnClasses = getColumnClasses(panelGrid, columns); String[] rowClasses = getRowClasses(panelGrid); int row = 0; int column = 0; List<UIComponent> children = panelGrid.getChildren(); for (UIComponent child : children) { if (0 == column) { generateRowStart(writer, row, rowClasses, panelGrid); } generateColumnStart(child, columnClasses[column], writer); child.encodeAll(context); generateColumnEnd(writer, columns[column]); column++; if (column >= columns.length) { generateRowEnd(writer, row, rowClasses); column = 0; row++; } } if (column != 0) { generateRowEnd(writer, row, rowClasses); column = 0; row++; } endDisabledFieldset(panelGrid, writer); generateContainerEnd(writer); if (null != responsiveStyle) { writer.endElement("div"); } Tooltip.activateTooltips(context, panelGrid); }