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"); } } }
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); } }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (context == null || component == null) { // PENDING - i18n throw new NullPointerException("'context' and/or 'component is null"); } // suppress rendering if "rendered" property on the component is // false. if (!component.isRendered()) { if (logger.isLoggable(Level.FINE)) { logger.fine( "End encoding component " + component.getId() + " since " + "rendered attribute is set to false "); } return; } ResponseWriter writer = context.getResponseWriter(); writer.endElement("groupbox"); writer.writeText("\n", null); if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "End encoding component " + component.getId()); } }
public void encodeChildren(FacesContext context, UIComponent component) throws IOException { if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "Begin encoding children " + component.getId()); } // suppress rendering if "rendered" property on the component is // false. if (!component.isRendered()) { if (logger.isLoggable(Level.FINE)) { logger.fine( "End encoding component " + component.getId() + " since " + "rendered attribute is set to false "); } return; } // Render our children recursively Iterator kids = getChildren(component); while (kids.hasNext()) { encodeRecursive(context, (UIComponent) kids.next()); } if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "End encoding children " + component.getId()); } }
/* (non-Javadoc) * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent) */ public void encodeChildren(FacesContext context, UIComponent component) throws IOException { // UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component; if ("none".equals(panel.getLayout())) { if (component.getChildCount() > 0) { AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context); boolean ajaxRequest = ajaxContext.isAjaxRequest(); Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas(); for (UIComponent child : component.getChildren()) { String childId = child.getClientId(context); if (child.isRendered()) { renderChild(context, child); } else { // Render "dummy" span. ResponseWriter out = context.getResponseWriter(); out.startElement(HTML.SPAN_ELEM, child); out.writeAttribute(HTML.id_ATTRIBUTE, childId, HTML.id_ATTRIBUTE); out.writeAttribute(HTML.style_ATTRIBUTE, "display: none;", "style"); out.endElement(HTML.SPAN_ELEM); } // register child as rendered if (ajaxRequest && null != ajaxRenderedAreas) { ajaxRenderedAreas.add(childId); } } } } else { renderChildren(context, component); } }
@Override public void decode(FacesContext context, UIComponent component) { super.decode(context, component); if (!component.isRendered()) { return; } Map<String, String> requestParameterMap = context.getExternalContext().getRequestParameterMap(); if (requestParameterMap.get(component.getClientId(context)) != null) { String xParam = requestParameterMap.get(getFieldId(component, X_VALUE)); String yParam = requestParameterMap.get(getFieldId(component, Y_VALUE)); String pointIndexParam = requestParameterMap.get(getFieldId(component, POINT_INDEX)); String eventTypeParam = requestParameterMap.get(getFieldId(component, EVENT_TYPE)); String seriesIndexParam = requestParameterMap.get(getFieldId(component, SERIES_INDEX)); try { if (PLOT_CLICK_TYPE.equals(eventTypeParam)) { double y = Double.parseDouble(yParam); int seriesIndex = Integer.parseInt(seriesIndexParam); int pointIndex = Integer.parseInt(pointIndexParam); String x = xParam; new PlotClickEvent(component, seriesIndex, pointIndex, x, y).queue(); } } catch (NumberFormatException ex) { throw new FacesException("Cannot convert request parmeters", ex); } } }
@Override public void encodeChildren(FacesContext context, UIComponent component) throws IOException { // Make sure this component is a 'when' component FacesUtil.AssertValidParams(context, component, UIChooseWhenComponent.class); // Make sure the parent of this component is a 'choose' component FacesUtil.AssertValidParams(context, component.getParent(), UIChooseComponent.class); // If this component is not rendered skip all the logic if (!component.isRendered()) { return; } UIChooseWhenComponent condComp = (UIChooseWhenComponent) component; UIChooseComponent chooseComp = (UIChooseComponent) component.getParent(); // Render children only if a true condition hasn't already been // evaluated (assure mutual exclusion). // if ( chooseComp.isFoundTrue() ) // { // return; // } // Render children only if the specified condition doesn't hold. if (condComp.getTest()) { super.encodeChildren(context, component); // chooseComp.setFoundTrue( true ); } }
public void encodeChildren(FacesContext facesContext, UIComponent uiComponent) throws IOException { validateParameters(facesContext, uiComponent, null); DOMContext domContext = DOMContext.attachDOMContext(facesContext, uiComponent); Element root = (Element) domContext.getRootNode(); DOMContext.removeChildren(root); PanelSeries list = (PanelSeries) uiComponent; UISeries uiList = (UISeries) uiComponent; int rowIndex = uiList.getFirst(); uiList.setRowIndex(rowIndex); int numberOfRowsToDisplay = uiList.getRows(); int countOfRowsDisplayed = 0; while (uiList.isRowAvailable()) { if ((numberOfRowsToDisplay > 0) && (countOfRowsDisplayed >= numberOfRowsToDisplay)) { break; } Iterator childs; childs = list.getChildren().iterator(); while (childs.hasNext()) { UIComponent nextChild = (UIComponent) childs.next(); if (nextChild.isRendered()) { domContext.setCursorParent(root); domContext.streamWrite(facesContext, uiComponent, domContext.getRootNode(), root); encodeParentAndChildren(facesContext, nextChild); } } rowIndex++; countOfRowsDisplayed++; uiList.setRowIndex(rowIndex); } uiList.setRowIndex(-1); }
/** * Return an Iterator over the <code>UIColumn</code> children of the specified <code>UIData * </code> that have a <code>rendered</code> property of <code>true</code>. * * @param table the table from which to extract children * @return the List of all UIColumn children */ private static List<UIColumn> getColumns(UIComponent table) { if (table instanceof UIData) { int childCount = table.getChildCount(); if (childCount > 0) { List<UIColumn> results = new ArrayList<UIColumn>(childCount); for (UIComponent kid : table.getChildren()) { if ((kid instanceof UIColumn) && kid.isRendered()) { results.add((UIColumn) kid); } } return results; } else { return Collections.emptyList(); } } else { int count; Object value = table.getAttributes().get("columns"); if ((value != null) && (value instanceof Integer)) { count = ((Integer) value); } else { count = 2; } if (count < 1) { count = 1; } List<UIColumn> result = new ArrayList<UIColumn>(count); for (int i = 0; i < count; i++) { result.add(PLACE_HOLDER_COLUMN); } return result; } }
@Override public void encodeChildren(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } FacesUtil.renderChildren(context, component); }
@Override public void encodeBegin(final FacesContext context, final UIComponent component) throws IOException { if (!component.isRendered()) { return; } final ResponseWriter writer = context.getResponseWriter(); final HtmlWaitingPanel waitingPanel = (HtmlWaitingPanel) component; final String style = waitingPanel.getStyle(); final String styleClass = waitingPanel.getStyleClass(); writer.startElement(ELEMENT_DIV, component); this.writeIdAttribute(context, writer, component); if (StringUtils.isNotEmpty(style)) { writer.writeAttribute("style", style, null); } if (StringUtils.isNotEmpty(styleClass)) { writer.writeAttribute("class", "butter-component-waitingPanel " + styleClass, null); } else { writer.writeAttribute("class", "butter-component-waitingPanel", null); } }
private void _createStation(UIXProcess process, UIComponent stamp, int index, boolean active) { process.setRowIndex(index); if (stamp.isRendered()) { // The station will be visible. _stations.add(new Station(this, stamp, index, process.getRowKey(), active)); } }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException { assertNotNull(context, component); if (!component.isRendered()) { return; } encodeHtmlSelectListboxEnd(context, component); }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if ((context == null) || (component == null)) { throw new NullPointerException( Util.getExceptionMessageString(Util.NULL_PARAMETERS_ERROR_MESSAGE_ID)); } if (!component.isRendered()) { if (log.isTraceEnabled()) { log.trace( "No encoding necessary " + component.getId() + " since " + "rendered attribute is set to false "); } return; } UIData data = (UIData) component; data.setRowIndex(-1); ResponseWriter writer = context.getResponseWriter(); // Render the ending of this table writer.endElement("table"); writer.writeText("\n", null); if (log.isTraceEnabled()) { log.trace("End encoding component " + component.getId()); } }
public void encodeBegin(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } ResponseWriter writer = context.getResponseWriter(); String jsfId = (String) RendererUtil.getAttribute(context, component, "id"); String id = jsfId; if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) { id = component.getClientId(context); } String title = (String) RendererUtil.getAttribute(context, component, "title"); Object tmpFoldStr = RendererUtil.getAttribute(context, component, "hideByDefault"); String key = (String) RendererUtil.getAttribute(context, component, "key"); writer.write("<fieldset>"); writer.write("<legend>"); writer.write( "<a role='button' data-toggle='collapse' aria-expanded='true' aria-target='" + id + "' href='#" + id + "' data-target=\"[id='" + id + "']\">" + title + "</a>"); writer.write("</legend>"); writer.write("<div class='collapse in' " + " id=\"" + id + "\">"); }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { super.encodeEnd(context, component); if (!(component.isRendered())) { return; } ResponseWriter writer = context.getResponseWriter(); newLine(writer); UIDojoAccordionContainer c = (UIDojoAccordionContainer) component; if (isTrackClientSelection()) { String id = c.getClientId(context) + _SELECTION; String selectedTab = c.getSelectedTab(); if (selectedTab == null) { selectedTab = ""; } writer.startElement("input", component); // this is for the uistate $NON-NLS-1$ writer.writeAttribute("id", id, null); // $NON-NLS-1$ writer.writeAttribute("name", id, null); // $NON-NLS-1$ writer.writeAttribute("type", "hidden", null); // $NON-NLS-1$ $NON-NLS-2$ writer.writeAttribute("value", selectedTab, null); // $NON-NLS-1$ writer.endElement("input"); // $NON-NLS-1$ } }
/** Find all parameters to include by looking at nested uiparams and params of navigation case */ protected static Map<String, List<String>> getParams(NavigationCase navCase, Button button) { Map<String, List<String>> params = new LinkedHashMap<String, List<String>>(); // UIParams for (UIComponent child : button.getChildren()) { if (child.isRendered() && (child instanceof UIParameter)) { UIParameter uiParam = (UIParameter) child; if (!uiParam.isDisable()) { List<String> paramValues = params.get(uiParam.getName()); if (paramValues == null) { paramValues = new ArrayList<String>(); params.put(uiParam.getName(), paramValues); } paramValues.add(String.valueOf(uiParam.getValue())); } } } // NavCase Params Map<String, List<String>> navCaseParams = navCase.getParameters(); if (navCaseParams != null && !navCaseParams.isEmpty()) { for (Map.Entry<String, List<String>> entry : navCaseParams.entrySet()) { String key = entry.getKey(); // UIParams take precedence if (!params.containsKey(key)) { params.put(key, entry.getValue()); } } } return params; }
protected void encodeTabs(FacesContext context, AccordionPanel acco) throws IOException { boolean dynamic = acco.isDynamic(); String var = acco.getVar(); List<String> activeIndexes = Arrays.asList(acco.getActiveIndex().split(",")); boolean rtl = acco.getDir().equalsIgnoreCase("rtl"); if (var == null) { int i = 0; for (UIComponent child : acco.getChildren()) { if (child.isRendered() && child instanceof Tab) { boolean active = activeIndexes.indexOf(Integer.toString(i)) != -1; encodeTab(context, acco, (Tab) child, active, dynamic, rtl); i++; } } } else { int dataCount = acco.getRowCount(); Tab tab = (Tab) acco.getChildren().get(0); for (int i = 0; i < dataCount; i++) { acco.setIndex(i); boolean active = activeIndexes.indexOf(Integer.toString(i)) != -1; encodeTab(context, acco, tab, active, dynamic, rtl); } acco.setIndex(-1); } }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } // Get the response renderer ResponseWriter writer = context.getResponseWriter(); // Do not render if it is not needed if (AjaxUtil.isAjaxNullResponseWriter(writer)) { return; } // Get the UIInput if (!(component instanceof UIInput)) { return; } UIInput uiInput = (UIInput) component; // And write the value String currentValue = computeValueAsISOString(context, uiInput); writeTag(context, uiInput, writer, currentValue); // TODO should change this to use InputRendererUtil.encodeValidation, // once it has been updated to support delegating to the renderer. // InputRendererUtil.encodeValidation(context, writer, uiInput); encodeValidation(context, writer, uiInput); InputRendererUtil.encodeDirtyState(context, writer, uiInput); }
/** Render column headers either in single row or nested if a columnGroup is defined */ protected void encodeThead(FacesContext context, DataTable table) throws IOException { ResponseWriter writer = context.getResponseWriter(); ColumnGroup group = table.getColumnGroup("header"); writer.startElement("thead", null); writer.writeAttribute("id", table.getClientId(context) + "_head", null); if (group != null && group.isRendered()) { for (UIComponent child : group.getChildren()) { if (child.isRendered() && child instanceof Row) { Row headerRow = (Row) child; writer.startElement("tr", null); for (UIComponent headerRowChild : headerRow.getChildren()) { if (headerRowChild.isRendered() && headerRowChild instanceof Column) { encodeColumnHeader(context, table, (Column) headerRowChild); } } writer.endElement("tr"); } } } else { writer.startElement("tr", null); writer.writeAttribute("role", "row", null); for (UIColumn column : table.getColumns()) { if (column instanceof Column) { encodeColumnHeader(context, table, column); } else if (column instanceof DynamicColumn) { DynamicColumn dynamicColumn = (DynamicColumn) column; dynamicColumn.applyModel(); encodeColumnHeader(context, table, dynamicColumn); } } writer.endElement("tr"); } encodeFrozenRows(context, table); writer.endElement("thead"); }
/** * Faces render output method . * * <p>Method Generator: org.sakaiproject.tool.assessment.devtools.RenderMaker * * @param context <code>FacesContext</code> for the current request * @param component <code>UIComponent</code> being rendered * @throws IOException if an input/output error occurs */ public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } ResponseWriter writer = context.getResponseWriter(); String clientId = null; if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) { clientId = component.getClientId(context); } if (clientId != null) { writer.startElement("span", component); writer.writeAttribute("id", clientId, "id"); } Map attrMap = component.getAttributes(); writer.write("\n"); writer.write("\n<script language=\"javascript\">"); writer.write("\n// Timer Bar - Version 1.0"); writer.write("\n// Based on Script by Brian Gosselin of http://scriptasylum.com"); writer.write("\n var loadedcolor='gray' ; // PROGRESS BAR COLOR"); writer.write("\n var unloadedcolor='green'; // COLOR OF UNLOADED AREA"); writer.write("\n var bordercolor='navy'; // COLOR OF THE BORDER"); writer.write( "\n var barheight = " + attrMap.get("height") + "; // HEIGHT OF PROGRESS BAR IN PIXELS"); writer.write("\n var barwidth = " + attrMap.get("width") + "; // WIDTH OF THE BAR IN PIXELS"); writer.write( "\n var waitTime = " + attrMap.get("wait") + "; // NUMBER OF SECONDS FOR PROGRESSBAR"); writer.write( "\n var loaded = " + attrMap.get("elapsed") + "*10; // TENTHS OF A SECOND ELAPSED"); writer.write("\n// THE FUNCTION BELOW CONTAINS THE ACTION(S) TAKEN ONCE BAR REACHES 100."); writer.write("\n"); writer.write("\n var action = function()"); writer.write("\n {"); writer.write("\n " + attrMap.get("expireScript") + ";"); writer.write("\n alert(\"" + attrMap.get("expireMessage") + "\");"); writer.write("\n }"); writer.write("\n"); writer.write("\n</script>"); writer.write( "\n<script language=\"javascript\" src=\"" + "/" + RESOURCE_PATH + "/" + SCRIPT_PATH + "\"></script>"); writer.write("\n"); if (clientId != null) { writer.endElement("span"); } }
public void encodeBegin(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) return; ResponseWriter writer = context.getResponseWriter(); writer.write("<p class=\"act\">\n"); return; }
protected void renderChildren( FacesContext context, ResponseWriter writer, UIComponent component, int columns) throws IOException { String rowClasses; if (component instanceof HtmlPanelGrid) { rowClasses = ((HtmlPanelGrid) component).getRowClasses(); } else { rowClasses = (String) component.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR); } String[] rowClassesArray = (rowClasses == null) ? org.apache.myfaces.shared_tomahawk.util.ArrayUtils.EMPTY_STRING_ARRAY : StringUtils.trim(StringUtils.splitShortString(rowClasses, ',')); int rowClassesCount = rowClassesArray.length; int childCount = getChildCount(component); if (childCount > 0) { int columnIndex = 0; int rowClassIndex = 0; boolean rowStarted = false; for (Iterator it = getChildren(component).iterator(); it.hasNext(); ) { UIComponent child = (UIComponent) it.next(); if (child.isRendered()) { if (columnIndex == 0) { // start of new/next row if (rowStarted) { // do we have to close the last row? writer.endElement(HTML.LI_ELEM); HtmlRendererUtils.writePrettyLineSeparator(context); } writer.startElement(HTML.LI_ELEM, component); if (rowClassIndex < rowClassesCount) { writer.writeAttribute(HTML.CLASS_ATTR, rowClassesArray[rowClassIndex], null); } rowStarted = true; rowClassIndex++; if (rowClassIndex == rowClassesCount) { rowClassIndex = 0; } } RendererUtils.renderChild(context, child); columnIndex++; if (columnIndex >= columns) { columnIndex = 0; } } } if (rowStarted) { writer.endElement(HTML.LI_ELEM); HtmlRendererUtils.writePrettyLineSeparator(context); } } }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } ResponseWriter writer = context.getResponseWriter(); writer.write("</div>"); writer.write("</fieldset>"); }
protected void encodeTFoot(FacesContext context, DataTable table) throws IOException { ResponseWriter writer = context.getResponseWriter(); ColumnGroup group = table.getColumnGroup("footer"); writer.startElement("tfoot", null); if (group != null && group.isRendered()) { for (UIComponent child : group.getChildren()) { if (child.isRendered() && child instanceof Row) { Row footerRow = (Row) child; writer.startElement("tr", null); for (UIComponent footerRowChild : footerRow.getChildren()) { if (footerRowChild.isRendered() && footerRowChild instanceof Column) { encodeColumnFooter(context, table, (Column) footerRowChild); } } writer.endElement("tr"); } } } else if (table.hasFooterColumn()) { writer.startElement("tr", null); for (UIColumn column : table.getColumns()) { if (column instanceof Column) { encodeColumnFooter(context, table, column); } else if (column instanceof DynamicColumn) { DynamicColumn dynamicColumn = (DynamicColumn) column; dynamicColumn.applyModel(); encodeColumnFooter(context, table, dynamicColumn); } } writer.endElement("tr"); } writer.endElement("tfoot"); }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) return; if (!isDisabled(context, component)) { // use default link rendering super.encodeEnd(context, component); } else { // rendering of end of disabled link taken care of already } }
private static boolean isRendered(UIComponent component) { UIComponent c = component; while (c != null) { if (!c.isRendered()) { return false; } c = c.getParent(); } return true; }
/** * This methods generates the HTML code of the current b:buttonToolbar. <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:buttonToolbar. * @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; } ButtonToolbar buttonToolbar = (ButtonToolbar) component; ResponseWriter rw = context.getResponseWriter(); String clientId = buttonToolbar.getClientId(); rw.endElement("buttonToolbar"); Tooltip.activateTooltips(fc, c.getAttributes(), c); }
/** * @param component Component from which to return a facet * @param name Name of the desired facet * @return the specified facet from the specified component, but <strong>only</strong> if its * <code>rendered</code> property is set to <code>true</code>. */ protected UIComponent getFacet(UIComponent component, String name) { UIComponent facet = null; if (component.getFacetCount() > 0) { facet = component.getFacet(name); if ((facet != null) && !facet.isRendered()) { facet = null; } } return (facet); }
/** * Return an Iterator over the <code>UIColumn</code> children of the specified <code>UIData</code> * that have a <code>rendered</code> property of <code>true</code>. * * @param data <code>UIData</code> for which to extract children */ private Iterator getColumns(UIData data) { List results = new ArrayList(); Iterator kids = data.getChildren().iterator(); while (kids.hasNext()) { UIComponent kid = (UIComponent) kids.next(); if ((kid instanceof UIColumn) && kid.isRendered()) { results.add(kid); } } return (results.iterator()); }