public void encodeTableFacet( FacesContext context, PanelGrid grid, int columns, String facet, String tag, String styleClass) throws IOException { UIComponent component = grid.getFacet(facet); if (component != null && component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); writer.startElement(tag, null); writer.writeAttribute("class", styleClass, null); if (columns > 0) { writer.startElement("tr", null); writer.writeAttribute("class", "ui-widget-header", null); writer.writeAttribute("role", "row", null); writer.startElement("td", null); writer.writeAttribute("colspan", columns, null); writer.writeAttribute("role", "columnheader", null); component.encodeAll(context); writer.endElement("td"); writer.endElement("tr"); } else { context.getAttributes().put(Constants.HELPER_RENDERER, "panelGridFacet"); if (component instanceof Row) { encodeRow( context, (Row) component, "columnheader", "ui-widget-header", PanelGrid.CELL_CLASS + " ui-widget-header"); } else if (component instanceof UIPanel) { for (UIComponent child : component.getChildren()) { if (child.isRendered()) { if (child instanceof Row) encodeRow( context, (Row) child, "columnheader", "ui-widget-header", PanelGrid.CELL_CLASS + " ui-widget-header"); else component.encodeAll(context); } } } else { component.encodeAll(context); } context.getAttributes().remove(Constants.HELPER_RENDERER); } writer.endElement(tag); } }
protected void encodeToolbarGroups(FacesContext context, Toolbar toolbar) throws IOException { ResponseWriter writer = context.getResponseWriter(); for (UIComponent child : toolbar.getChildren()) { if (child.isRendered() && child instanceof ToolbarGroup) { ToolbarGroup group = (ToolbarGroup) child; String defaultGroupClass = "ui-toolbar-group-" + group.getAlign(); String groupClass = group.getStyleClass(); String groupStyle = group.getStyle(); groupClass = groupClass == null ? defaultGroupClass : defaultGroupClass + " " + groupClass; writer.startElement("div", null); writer.writeAttribute("class", groupClass, null); if (groupStyle != null) { writer.writeAttribute("style", groupStyle, null); } for (UIComponent groupChild : group.getChildren()) { if (groupChild instanceof UISeparator && groupChild.isRendered()) encodeSeparator(context, (UISeparator) groupChild); else groupChild.encodeAll(context); } writer.endElement("div"); } } }
/** * Encode the case when the <code>var</code> attribute is specified. This will render without any * HTML markup and put the current message in the request scope as identified by the <code>var * </code> attribute. Note: the iteration is by design completely stateless. * * @param context The involved faces context. * @param component The messages component. * @param messages The queued faces messages. * @throws IOException When an I/O error occurs. */ protected void encodeMessagesRepeater( FacesContext context, OmniMessages component, List<FacesMessage> messages) throws IOException { String var = component.getVar(); Map<String, Object> requestMap = context.getExternalContext().getRequestMap(); Object originalVar = requestMap.get(var); try { for (FacesMessage message : messages) { if (message.isRendered() && !component.isRedisplay()) { continue; } requestMap.put(var, message); for (UIComponent child : component.getChildren()) { child.encodeAll(context); } message.rendered(); } } finally { if (originalVar != null) { requestMap.put(var, originalVar); } else { requestMap.remove(var); } } }
protected void encodeColumnFooter(FacesContext context, DataTable table, UIColumn column) throws IOException { if (!column.isRendered()) { return; } ResponseWriter writer = context.getResponseWriter(); String style = column.getStyle(); String styleClass = column.getStyleClass(); styleClass = styleClass == null ? DataTable.COLUMN_FOOTER_CLASS : DataTable.COLUMN_FOOTER_CLASS + " " + styleClass; writer.startElement("td", null); writer.writeAttribute("class", styleClass, null); if (style != null) writer.writeAttribute("style", style, null); if (column.getRowspan() != 1) writer.writeAttribute("rowspan", column.getRowspan(), null); if (column.getColspan() != 1) writer.writeAttribute("colspan", column.getColspan(), null); // Footer content UIComponent facet = column.getFacet("footer"); String text = column.getFooterText(); if (facet != null) { facet.encodeAll(context); } else if (text != null) { writer.write(text); } writer.endElement("td"); }
@Override public void encodeChildren(FacesContext facesContext, UIComponent uiComponent) throws IOException { List<UIComponent> children = uiComponent.getChildren(); if (children != null) { for (UIComponent child : children) { child.encodeAll(facesContext); } } }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIViewRoot viewRoot = context.getViewRoot(); ListIterator iter = (viewRoot.getComponentResources(context, "body")).listIterator(); while (iter.hasNext()) { UIComponent resource = (UIComponent) iter.next(); resource.encodeAll(context); } RenderKitUtils.renderUnhandledMessages(context); writer.endElement("body"); }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); // Last facet UIComponent last = component.getFacet("last"); if (last != null) { last.encodeAll(context); } writer.endElement("head"); }
protected void encodeFacet(FacesContext context, Toolbar toolbar, String facetName) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIComponent facet = toolbar.getFacet(facetName); if (facet != null) { writer.startElement("div", null); writer.writeAttribute("class", "ui-toolbar-group-" + facetName, null); facet.encodeAll(context); writer.endElement("div"); } }
private void encodeLoading(ResponseWriter writer, FacesContext context, AbstractTooltip tooltip) throws IOException { writer.startElement(getMarkupElement(tooltip), tooltip); writer.writeAttribute(ID_ATTRIBUTE, tooltip.getClientId(context) + ":loading", null); writer.writeAttribute(CLASS_ATTRIBUTE, "rf-tt-loading", null); UIComponent loading = tooltip.getFacet("loading"); if (loading != null && loading.isRendered()) { loading.encodeAll(context); } else { writer.writeText("Loading...", null); } writer.endElement(getMarkupElement(tooltip)); }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { SecurityArea securityArea = (SecurityArea) component; if (securityArea.isRendered() && securityArea.getChildCount() > 0) { if (allow( securityArea.getRolesAllowed(), securityArea.getRolesForbidden(), component, context)) { for (UIComponent child : securityArea.getChildren()) { if (child.isRendered()) { child.encodeAll(context); } } } } }
protected void encodeFacet( FacesContext context, DataTable table, UIComponent facet, String styleClass) throws IOException { if (facet == null) return; ResponseWriter writer = context.getResponseWriter(); writer.startElement("div", null); writer.writeAttribute("class", styleClass, null); facet.encodeAll(context); writer.endElement("div"); }
@Override public void renderChildren(FacesContext facesContext, UIComponent component) throws IOException { AbstractDropDownMenu dropDownMenu = (AbstractDropDownMenu) component; for (UIComponent child : dropDownMenu.getChildren()) { if (child.isRendered() && (child instanceof AbstractMenuGroup || child instanceof AbstractMenuItem || child instanceof AbstractMenuSeparator)) { child.encodeAll(facesContext); } } }
public void encodeItem(FacesContext facesContext, UIComponent component) throws IOException { ResponseWriter writer = facesContext.getResponseWriter(); writer.startElement(HtmlConstants.TR_ELEMENT, component); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm", null); for (UIComponent child : component.getChildren()) { if (child instanceof UIColumn) { encodeItemChildBegin(facesContext, component); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-fnt rf-au-inp", null); child.encodeAll(facesContext); encodeItemChildEnd(facesContext, component); } } writer.endElement(HtmlConstants.TR_ELEMENT); }
@Override protected void doEncodeChildren( ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { AbstractTooltip tooltip = (AbstractTooltip) component; if (tooltip.getMode() == TooltipMode.client) { if (tooltip.getChildCount() > 0) { for (UIComponent kid : tooltip.getChildren()) { kid.encodeAll(context); } } } }
public void encodeGridFacet( FacesContext context, PanelGrid grid, int columns, String facet, String styleClass) throws IOException { UIComponent component = grid.getFacet(facet); if (component != null && component.isRendered()) { ResponseWriter writer = context.getResponseWriter(); writer.startElement("div", null); writer.writeAttribute("class", styleClass + " ui-widget-header", null); component.encodeAll(context); writer.endElement("div"); } }
public void encodeFacet( ResponseWriter writer, FacesContext facesContext, UIComponent facet, EncodeStrategy strategy, AbstractDataGrid dataGrid, Object[] params) throws IOException { if (facet != null && facet.isRendered()) { strategy.begin(writer, facesContext, dataGrid, params); facet.encodeAll(facesContext); strategy.end(writer, facesContext, dataGrid, params); } }
public VisitResult visit(VisitContext context, UIComponent comp) { try { if (curPhase == PhaseId.APPLY_REQUEST_VALUES) { // RELEASE_PENDING handle immediate request(s) // If the user requested an immediate request // Make sure to set the immediate flag here. comp.processDecodes(ctx); } else if (curPhase == PhaseId.PROCESS_VALIDATIONS) { comp.processValidators(ctx); } else if (curPhase == PhaseId.UPDATE_MODEL_VALUES) { comp.processUpdates(ctx); } else if (curPhase == PhaseId.RENDER_RESPONSE) { PartialResponseWriter writer = ctx.getPartialViewContext().getPartialResponseWriter(); writer.startUpdate(comp.getClientId(ctx)); try { // do the default behavior... comp.encodeAll(ctx); } catch (Exception ce) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe(ce.toString()); } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, ce.toString(), ce); } } writer.endUpdate(); } else { throw new IllegalStateException( "I18N: Unexpected " + "PhaseId passed to " + " PhaseAwareContextCallback: " + curPhase.toString()); } } catch (IOException ex) { ex.printStackTrace(); } // Once we visit a component, there is no need to visit // its children, since processDecodes/Validators/Updates and // encodeAll() already traverse the subtree. We return // VisitResult.REJECT to supress the subtree visit. return VisitResult.REJECT; }
protected void encodeHeader(FacesContext context, Panel panel) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIComponent header = panel.getFacet("header"); String headerText = panel.getHeader(); String clientId = panel.getClientId(context); if (headerText == null && header == null) { return; } writer.startElement("div", null); writer.writeAttribute("id", panel.getClientId(context) + "_header", null); writer.writeAttribute("class", Panel.PANEL_TITLEBAR_CLASS, null); // Title writer.startElement("span", null); writer.writeAttribute("class", Panel.PANEL_TITLE_CLASS, null); if (header != null) { renderChild(context, header); } else if (headerText != null) { writer.writeText(headerText, null); } writer.endElement("span"); // Options if (panel.isClosable()) { encodeIcon(context, panel, "ui-icon-closethick", clientId + "_closer", panel.getCloseTitle()); } if (panel.isToggleable()) { String icon = panel.isCollapsed() ? "ui-icon-plusthick" : "ui-icon-minusthick"; encodeIcon(context, panel, icon, clientId + "_toggler", panel.getToggleTitle()); } if (panel.getOptionsMenu() != null) { encodeIcon(context, panel, "ui-icon-gear", clientId + "_menu", panel.getMenuTitle()); } // Actions UIComponent actionsFacet = panel.getFacet("actions"); if (actionsFacet != null) { actionsFacet.encodeAll(context); } writer.endElement("div"); }
public static void writeFacetOrAttr( ResponseWriter writer, FacesContext context, UIComponent component, String attr, UIComponent headerFacet) throws IOException { if (headerFacet != null && headerFacet.isRendered()) { headerFacet.encodeAll(context); } else { Object label = component.getAttributes().get(attr); if (label != null && !label.equals("")) { writer.writeText(label, null); } } }
@Override public void encodeChildren(FacesContext context, UIComponent component) throws IOException { if (component.getChildCount() > 0) { if (component.getRendersChildren()) { Iterator<UIComponent> iterator = component.getChildren().iterator(); while (iterator.hasNext()) { UIComponent uiComponent = (UIComponent) iterator.next(); // if (uiComponent instanceof UIInputTipsy) // { uiComponent.encodeAll(context); // } } } } }
private void renderAll(FacesContext context, UIViewRoot viewRoot) throws IOException { // If this is a "render all via ajax" request, // make sure to wrap the entire page in a <render> elemnt // with the special id of VIEW_ROOT_ID. This is how the client // JavaScript knows how to replace the entire document with // this response. PartialResponseWriter writer = getPartialResponseWriter(); writer.startUpdate(PartialResponseWriter.RENDER_ALL_MARKER); Iterator<UIComponent> itr = viewRoot.getFacetsAndChildren(); while (itr.hasNext()) { UIComponent kid = itr.next(); kid.encodeAll(context); } writer.endUpdate(); }
private void encodeTabHeader( FacesContext context, AbstractTab tab, ResponseWriter writer, AbstractTogglePanelTitledItem.HeaderStates state, Boolean isDisplay) throws IOException { String headerStateClass = "rf-tab-hdr-" + state.abbreviation(); String headerPositionClass = "rf-tab-hdr-" + positionAbbreviation(tab); writer.startElement(TD_ELEM, tab); writer.writeAttribute( ID_ATTRIBUTE, tab.getClientId(context) + ":header:" + state.toString(), null); renderPassThroughAttributes(context, tab, HEADER_ATTRIBUTES); writer.writeAttribute( CLASS_ATTRIBUTE, concatClasses( "rf-tab-hdr", headerStateClass, headerPositionClass, attributeAsString(tab, "headerClass"), attributeAsString(tab, state.headerClass())), null); writer.writeAttribute( STYLE_ATTRIBUTE, concatStyles(isDisplay ? "" : "display : none", attributeAsString(tab, "headerStyle")), null); writer.startElement(SPAN_ELEM, tab); writer.writeAttribute(CLASS_ATTRIBUTE, "rf-tab-lbl", null); UIComponent headerFacet = tab.getHeaderFacet(state); if (headerFacet != null && headerFacet.isRendered()) { headerFacet.encodeAll(context); } else { Object headerText = tab.getAttributes().get("header"); if (headerText != null && !headerText.equals("")) { writer.writeText(headerText, null); } } writer.endElement(SPAN_ELEM); writer.endElement(TD_ELEM); }
public void encodeMetaComponent( FacesContext context, UIComponent component, String metaComponentId) throws IOException { if (AbstractTooltip.CONTENT_META_COMPONENT_ID.equals(metaComponentId)) { AbstractTooltip tooltip = (AbstractTooltip) component; PartialResponseWriter writer = context.getPartialViewContext().getPartialResponseWriter(); writer.startUpdate( tooltip.getClientId(context) + ":" + AbstractTooltip.CONTENT_META_COMPONENT_ID); encodeContentBegin(writer, context, tooltip); for (UIComponent child : tooltip.getChildren()) { child.encodeAll(context); } encodeContentEnd(writer, context, tooltip); writer.endUpdate(); } }
private void renderAll(FacesContext context, UIViewRoot viewRoot) throws IOException { // If this is a "render all via ajax" request, // make sure to wrap the entire page in a <render> elemnt // with the special viewStateId of VIEW_ROOT_ID. This is how the client // JavaScript knows how to replace the entire document with // this response. PartialViewContext pvc = context.getPartialViewContext(); PartialResponseWriter writer = pvc.getPartialResponseWriter(); writer.startUpdate(PartialResponseWriter.RENDER_ALL_MARKER); if (viewRoot.getChildCount() > 0) { for (UIComponent uiComponent : viewRoot.getChildren()) { uiComponent.encodeAll(context); } } writer.endUpdate(); }
public void encodeGridBody(FacesContext context, PanelGrid grid, int columns) throws IOException { String clientId = grid.getClientId(); ResponseWriter writer = context.getResponseWriter(); String columnClassesValue = grid.getColumnClasses(); String[] columnClasses = columnClassesValue == null ? new String[0] : columnClassesValue.split(","); writer.startElement("div", grid); writer.writeAttribute("id", clientId + "_content", null); writer.writeAttribute("class", PanelGrid.CONTENT_CLASS, null); int i = 0; for (UIComponent child : grid.getChildren()) { if (!child.isRendered()) { continue; } int colMod = i % columns; if (colMod == 0) { writer.startElement("div", null); writer.writeAttribute("class", PanelGrid.GRID_ROW_CLASS, null); } String columnClass = (colMod < columnClasses.length) ? PanelGrid.CELL_CLASS + " " + columnClasses[colMod].trim() : PanelGrid.CELL_CLASS; columnClass = columnClass + " " + GridLayoutUtils.getColumnClass(columns); writer.startElement("div", null); writer.writeAttribute("class", columnClass, null); child.encodeAll(context); writer.endElement("div"); i++; colMod = i % columns; if (colMod == 0) { writer.endElement("div"); } } writer.endElement("div"); }
protected void encodeMarkup(FacesContext context, ConfirmationDialog dialog) throws IOException { ResponseWriter writer = context.getResponseWriter(); String clientId = dialog.getClientId(context); String messageText = dialog.getMessage(); UIComponent messageFacet = dialog.getFacet("message"); writer.startElement("div", null); writer.writeAttribute("id", clientId, null); writer.startElement("div", null); String header = dialog.getHeader(); if (header != null) { writer.writeAttribute("title", header, null); } // body writer.startElement("p", null); // severity writer.startElement("span", null); writer.writeAttribute("style", "float: left; margin: 0pt 7px 20px 0pt;", null); writer.writeAttribute("class", "ui-icon ui-icon-" + dialog.getSeverity(), null); writer.endElement("span"); if (messageFacet != null) { messageFacet.encodeAll(context); } else if (messageText != null) { writer.write(messageText); } writer.endElement("p"); // buttons writer.startElement("div", null); writer.writeAttribute("id", clientId + "_buttons", null); renderChildren(context, dialog); writer.endElement("div"); writer.endElement("div"); encodeScript(context, dialog); writer.endElement("div"); }
protected void encodeColumnHeaderContent(FacesContext context, UIColumn column, String sortIcon) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIComponent header = column.getFacet("header"); String headerText = column.getHeaderText(); writer.startElement("span", null); if (header != null) header.encodeAll(context); else if (headerText != null) writer.write(headerText); writer.endElement("span"); if (sortIcon != null) { writer.startElement("span", null); writer.writeAttribute("class", sortIcon, null); writer.endElement("span"); } }
public void encodeStaticBody(FacesContext context, PanelGrid grid) throws IOException { context.getAttributes().put(Constants.HELPER_RENDERER, "panelGridBody"); int i = 0; for (UIComponent child : grid.getChildren()) { if (child.isRendered()) { if (child instanceof Row) { String rowStyleClass = i % 2 == 0 ? PanelGrid.TABLE_ROW_CLASS + " " + PanelGrid.EVEN_ROW_CLASS : PanelGrid.TABLE_ROW_CLASS + " " + PanelGrid.ODD_ROW_CLASS; encodeRow(context, (Row) child, "gridcell", rowStyleClass, PanelGrid.CELL_CLASS); i++; } else { child.encodeAll(context); } } } context.getAttributes().remove(Constants.HELPER_RENDERER); }
public void encodeDynamicBody(FacesContext context, PanelGrid grid, int columns) throws IOException { ResponseWriter writer = context.getResponseWriter(); String columnClassesValue = grid.getColumnClasses(); String[] columnClasses = columnClassesValue == null ? new String[0] : columnClassesValue.split(","); int i = 0; for (UIComponent child : grid.getChildren()) { if (!child.isRendered()) { continue; } int colMod = i % columns; if (colMod == 0) { writer.startElement("tr", null); writer.writeAttribute("class", PanelGrid.TABLE_ROW_CLASS, null); writer.writeAttribute("role", "row", null); } String columnClass = (colMod < columnClasses.length) ? PanelGrid.CELL_CLASS + " " + columnClasses[colMod].trim() : PanelGrid.CELL_CLASS; writer.startElement("td", null); writer.writeAttribute("role", "gridcell", null); writer.writeAttribute("class", columnClass, null); child.encodeAll(context); writer.endElement("td"); i++; colMod = i % columns; if (colMod == 0) { writer.endElement("tr"); } } }
public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase holder) throws IOException { RowHolder rowHolder = (RowHolder) holder; Row row = rowHolder.getRow(); putRowStylesIntoContext(facesContext, rowHolder); rowHolder.setRowStart(true); Iterator<UIComponent> components = row.columns(); if (rowHolder.isUpdatePartial()) { partialStart( facesContext, ((AbstractCollapsibleSubTable) row).getRelativeClientId(facesContext) + ":b"); } int columnNumber = 0; while (components.hasNext()) { UIComponent component = components.next(); if (component.isRendered()) { if (component instanceof UIColumn) { component.getAttributes().put(COLUMN_CLASS, getColumnClass(rowHolder, columnNumber)); encodeColumn(facesContext, writer, (UIColumn) component, rowHolder); columnNumber++; } else if (component instanceof AbstractCollapsibleSubTable) { if (component.isRendered()) { encodeRowEnd(writer); } component.encodeAll(facesContext); rowHolder.setRowStart(true); } } } encodeRowEnd(writer); if (rowHolder.isUpdatePartial()) { partialEnd(facesContext); } }