Java Code Examples for javax.faces.context.ResponseWriter#writeAttribute()
The following examples show how to use
javax.faces.context.ResponseWriter#writeAttribute() .
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: FormTableRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
@Override protected void writeMainTableTag(FacesContext context, ResponseWriter w, FormLayout c) throws IOException { String ariaLabel = c.getAriaLabel(); if (StringUtil.isNotEmpty(ariaLabel)) { w.writeAttribute("aria-label", ariaLabel, null); // $NON-NLS-1$ } //Defect 198008 - a11y fix, need to add aria-labelledby w.writeAttribute("aria-labelledby", c.getClientId(context) + "_title", null); // $NON-NLS-1$ $NON-NLS-2$ String tbStyle = (String)getProperty(PROP_TABLESTYLE); if(StringUtil.isNotEmpty(tbStyle)) { w.writeAttribute("style", tbStyle, null); // $NON-NLS-1$ } String tbStyleClass = (String)getProperty(PROP_TABLESTYLECLASS); if(StringUtil.isNotEmpty(tbStyleClass)) { w.writeAttribute("class", tbStyleClass, null); // $NON-NLS-1$ } String tbRole = (String)getProperty(PROP_TABLEROLE); if(StringUtil.isNotEmpty(tbRole)) { w.writeAttribute("role", tbRole, null); // $NON-NLS-1$ } }
Example 2
Source File: FormTableRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
@Override protected void writeFooterFacet(FacesContext context, ResponseWriter w, FormLayout c, UIComponent footer) throws IOException { BootstrapUtil.startFullWidthRow(w, c); w.startElement("div", c); // $NON-NLS-1$ String style = (String)getProperty(PROP_STYLEFOOTER); if(StringUtil.isNotEmpty(style)) { w.writeAttribute("style", style, null); // $NON-NLS-1$ } String cls = (String)getProperty(PROP_STYLECLASSFOOTER); if(StringUtil.isNotEmpty(cls)) { w.writeAttribute("class", cls, null); // $NON-NLS-1$ } writeFooterFacetContent(context, w, c, footer); w.endElement("div"); // $NON-NLS-1$ BootstrapUtil.endFullWidthRow(w); }
Example 3
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 4
Source File: HtmlSortHeaderRenderer.java From sakai with Educational Community License v2.0 | 5 votes |
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException { if (log.isDebugEnabled()) log.debug("encodeEnd rendering " + component); if (!UserRoleUtils.isEnabledOnUserRole(component)) { super.encodeEnd(facesContext, component); } else { HtmlCommandSortHeader sortHeader = (HtmlCommandSortHeader) component; HtmlDataTable dataTable = sortHeader.findParentDataTable(); if (sortHeader.isArrow() && sortHeader.getColumnName().equals(dataTable.getSortColumn())) { ResponseWriter writer = facesContext.getResponseWriter(); writer.write(HTML.NBSP_ENTITY); HtmlGraphicImage image = new HtmlGraphicImage(); if (dataTable.isSortAscending()) { image.setValue("/library/image/sakai/sortascending.gif"); image.setAlt(MessageFormat.format(rb.getString("sort_ascending"), sortHeader.getColumnName().toLowerCase())); } else { image.setValue("/library/image/sakai/sortdescending.gif"); image.setAlt(MessageFormat.format(rb.getString("sort_descending"), sortHeader.getColumnName().toLowerCase())); } writer.startElement(HTML.IMG_ELEM, image); writer.writeURIAttribute("src", image.getValue(), null); writer.writeAttribute("alt",image.getAlt().toString(), null); writer.endElement(HTML.IMG_ELEM); } super.encodeEnd(facesContext, component); } }
Example 5
Source File: TabViewRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Generate an individual tab. Basically, that's <li role="presentation" * class="active"><a href="#{clientID}" role="tab" data-toggle="tab"< * {{title}} >/a> * * @param context * the current FacesContext * @param writer * the response writer * @param tab * the tab to be rendered. * @param isActive * is the current tab active? * @throws IOException * only thrown if something's wrong with the response writer */ private static void encodeTab(FacesContext context, ResponseWriter writer, UIComponent child, boolean isActive, String hiddenInputFieldID, int tabIndex, boolean disabled) throws IOException { Tab tab = (Tab) child; if (!tab.isRendered()) return; writer.startElement("li", tab); if (tab.getDir() != null) writer.writeAttribute("dir", tab.getDir(), "dir"); writer.writeAttribute("id", tab.getClientId(), "id"); writer.writeAttribute("role", "presentation", "role"); Tooltip.generateTooltip(context, tab, writer); String classes = isActive ? "active" : ""; if (tab.getStyleClass() != null) { classes += " "; classes += tab.getStyleClass(); } if (tab.isDisabled() || disabled) { classes += " disabled"; } if (classes.length() > 0) { writer.writeAttribute("class", classes.trim(), "class"); } if (tab.isDisabled() || disabled) { writer.writeAttribute("onclick", "event.preventDefault(); return false;", null); } if (tab.getStyle() != null) { writer.writeAttribute("style", tab.getStyle(), "style"); } encodeTabAnchorTag(context, writer, tab, hiddenInputFieldID, tabIndex, disabled); writer.endElement("li"); Tooltip.activateTooltips(context, tab); }
Example 6
Source File: WidgetContainerRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected void writeBodyScrollUpAltText(FacesContext context, ResponseWriter w, UIWidgetContainer c) throws IOException { String alt = (String)getProperty(PROP_CSSSCROLLUPALTTEXT); if(StringUtil.isNotEmpty(alt)) { w.startElement("span", c); // $NON-NLS-1$ w.writeAttribute("class", "lotusAltText", null); //$NON-NLS-1$ //$NON-NLS-2$ w.writeText(alt, "\u25B2"); //$NON-NLS-1$ w.endElement("span"); // $NON-NLS-1$ } }
Example 7
Source File: CarouselRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public void writeSlideButton(FacesContext context, ResponseWriter w, UICarousel c, SlideNode slide, String buttonText) throws IOException { if(StringUtil.isNotEmpty(buttonText)) { String buttonHref = slide.getButtonHref(); String buttonStyle = slide.getButtonStyle(); String buttonClass = slide.getButtonStyleClass(); // write button container String contTag = (String)getProperty(PROP_SLIDE_BTN_CONTAINER_TAG); w.startElement(contTag, c); w.writeAttribute("class", (String)getProperty(PROP_SLIDE_BTN_CONTAINER_CLASS), null); // $NON-NLS-1$ String tag = (String)getProperty(PROP_SLIDE_BTN_TAG); w.startElement(tag, c); String role = (String)getProperty(PROP_SLIDE_BTN_ROLE); w.writeAttribute("role", role, null); // $NON-NLS-1$ String classMixin = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_SLIDE_BTN_CLASS), buttonClass); if(StringUtil.isNotEmpty(classMixin)) { w.writeAttribute("class", classMixin, null); // $NON-NLS-1$ } String styleMixin = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_SLIDE_BTN_STYLE), buttonStyle); if(StringUtil.isNotEmpty(styleMixin)) { w.writeAttribute("style", styleMixin, null); // $NON-NLS-1$ } if(StringUtil.isNotEmpty(buttonHref)) { RenderUtil.writeLinkAttribute(context,w,buttonHref); } // write button text w.writeText(buttonText, null); // end button tag w.endElement(tag); // end button container w.endElement(contTag); } }
Example 8
Source File: JsfRenderUtils.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
private static void renderEmptyHiddenField(String clientId, ResponseWriter writer) throws IOException { writer.startElement("input", null); writer.writeAttribute("type", "hidden", null); writer.writeAttribute("id", clientId, null); writer.writeAttribute("name", clientId, null); writer.writeAttribute("value", "", null); writer.endElement("input"); }
Example 9
Source File: ForumViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected void writeCollapsibleContent(FacesContext context, ResponseWriter w, AbstractDataView c, ViewDefinition viewDef) throws IOException { // The style here is ensuring a float: left positioning w.startElement("div",c); // $NON-NLS-1$ String st2 = (String)getProperty(PROP_COLLAPSIBLEDIVSTYLE); if(StringUtil.isNotEmpty(st2)) { w.writeAttribute("style", st2, null); // $NON-NLS-1$ } writeShowHideDetailContent(context, w, c, viewDef); w.endElement("div"); // $NON-NLS-1$ }
Example 10
Source File: WidgetContainerRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected void writeFooter(FacesContext context, ResponseWriter w, UIWidgetContainer c) throws IOException { UIComponent footer = c.getFacet(UIWidgetContainer.FACET_FOOTER); if(footer!=null) { String tag = (String)getProperty(PROP_TAGFOOTER); w.startElement(tag, null); String cls = (String)getProperty(PROP_CSSFOOTER); if(StringUtil.isNotEmpty(cls)) { w.writeAttribute("class", cls, null); // $NON-NLS-1$ } FacesUtil.renderChildren(context, footer); w.endElement(tag); } }
Example 11
Source File: MobileFormTableRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override protected void writeFormTitle(FacesContext context, ResponseWriter w, FormLayout c, String title, String description) throws IOException { w.startElement("div", c); // $NON-NLS-1$ String style = (String)getProperty(PROP_STYLEHEADER); if(StringUtil.isNotEmpty(style)) { w.writeAttribute("style", style, null); // $NON-NLS-1$ } String cls = (String)getProperty(PROP_STYLECLASSHEADER); if(StringUtil.isNotEmpty(cls)) { w.writeAttribute("class", cls, null); // $NON-NLS-1$ } writeFormTitleContent(context, w, c, title, description); w.endElement("div"); // $NON-NLS-1$ }
Example 12
Source File: ShakeRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * This methods generates the HTML code of the current b:shake. * @param context the FacesContext. * @param component the current b:shake. * @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; } Shake shake = (Shake) component; ResponseWriter rw = context.getResponseWriter(); String clientId = shake.getClientId(); rw.startElement("script", shake); rw.writeAttribute("id", clientId, null); rw.write("\nvar myShakeEvent = new Shake({\n"); rw.write(" threshold: " + shake.getThreshold() + ",\n"); rw.write(" timeout: " + shake.getInterval() + "\n"); rw.write("});\n"); if (!shake.isDisabled()) { // Start listening to device motion: rw.write("myShakeEvent.start();\n"); } // Register a shake event listener on window with your callback: rw.write("window.addEventListener('shake', function(){\n"); String code = new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForAnMobileEvent(context, shake, rw, "shake"); rw.write(code + "\n"); rw.write("}, false);\n"); rw.endElement("script"); }
Example 13
Source File: DataTableRenderer.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
/** * This methods generates the HTML code of the current b:dataTable. <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:dataTable. * @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; } DataTable dataTable = (DataTable) component; ResponseWriter rw = context.getResponseWriter(); String clientId = dataTable.getClientId(); boolean idHasBeenRendered = false; if (dataTable.isScrollHorizontally()) { rw.startElement("div", dataTable); rw.writeAttribute("class", "table-responsive", null); rw.writeAttribute("id", clientId, "id"); idHasBeenRendered = true; } String responsiveStyle = Responsive.getResponsiveStyleClass(dataTable, false); if (null != responsiveStyle && responsiveStyle.trim().length() > 0) { rw.startElement("div", dataTable); rw.writeAttribute("class", responsiveStyle.trim(), null); if (!idHasBeenRendered) { rw.writeAttribute("id", clientId, "id"); idHasBeenRendered = true; } } if (dataTable.isContentDisabled()) { if (beginDisabledFieldset(dataTable, rw)) { rw.writeAttribute("id", clientId, "id"); idHasBeenRendered = true; } } rw.startElement("table", dataTable); if (!idHasBeenRendered) { rw.writeAttribute("id", clientId, "id"); } else { rw.writeAttribute("id", clientId + "Inner", "id"); // Table selection needs a valid AJAX id on the table tag } String styleClass = "table "; if (dataTable.isBorder()) { styleClass += "table-bordered "; } if (dataTable.isStriped()) { styleClass += "table-striped "; } if (dataTable.isRowHighlight()) { styleClass += "table-hover "; } if (dataTable.getStyleClass() != null) { styleClass += dataTable.getStyleClass(); } styleClass += " " + clientId.replace(":", "") + "Table"; rw.writeAttribute("class", styleClass, "class"); Tooltip.generateTooltip(context, dataTable, rw); rw.writeAttribute("cellspacing", "0", "cellspacing"); rw.writeAttribute("style", dataTable.getStyle(), "style"); AJAXRenderer.generateBootsFacesAJAXAndJavaScript(context, dataTable, rw, false); generateCaption(context, dataTable, rw); generateHeader(context, dataTable, rw); generateBody(context, dataTable, rw); generateFooter(context, dataTable, rw); new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForJQuery(context, component, rw, "." + clientId.replace(":", "") + "Table", null); }
Example 14
Source File: PagerRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
protected void encodeAction(FacesContext context, XspPager pager, UIPager.PagerState st, ResponseWriter writer, XspPagerControl control, String type, int start, int end, boolean RTL) throws IOException { String clientId = pager.getClientId(context); String controlId = clientId + "__" + type; String defaultText = ""; String ariaLabel = ""; boolean renderLink = true; //TODO need to handle BIDI here for the unicode symbols if (isFirst(type)) { renderLink = st.getCurrentPage() > start; // "\u00AB" FirstSymbol defaultText = "\u00AB"; //$NON-NLS-1$ // "First page" ariaLabel = com.ibm.xsp.extlib.controls.ResourceHandler.getString("PagerRenderer.Firstpage"); //$NON-NLS-1$ } else if (isPrevious(type)) { renderLink = st.getCurrentPage() > start; // "\u2039" PreviousSymbol defaultText = "\u2039"; //$NON-NLS-1$ // "Previous page" ariaLabel = com.ibm.xsp.extlib.controls.ResourceHandler.getString("PagerRenderer.Previouspage"); //$NON-NLS-1$ } else if (isNext(type)) { renderLink = st.getCurrentPage() < end - 1; // "\u203A" NextSymbol defaultText = "\u203A"; //$NON-NLS-1$; // "Next page" ariaLabel = com.ibm.xsp.extlib.controls.ResourceHandler.getString("PagerRenderer.Nextpage"); //$NON-NLS-1$ } else if (isLast(type)) { renderLink = st.getCurrentPage() < end - 1; // "\u00BB" LastSymbol defaultText = "\u00BB"; //$NON-NLS-1$ // "Last page" ariaLabel = com.ibm.xsp.extlib.controls.ResourceHandler.getString("PagerRenderer.Lastpage"); //$NON-NLS-1$ } writer.startElement("li", null); // $NON-NLS-1$ String listItemClass = (String)getProperty(PROP_LISTITEMCLASS); if(!renderLink) { //If current page is the first, disable first/previous pagers //and if current page is the last, disable last/next pagers listItemClass = ExtLibUtil.concatStyleClasses(listItemClass, (String)getProperty(PROP_DISABLEDCLASS)); } if(StringUtil.isNotEmpty(listItemClass)) { writer.writeAttribute("class", listItemClass, null); // $NON-NLS-1$ } // Generate the image link String val = (String) control.getValue(); if (StringUtil.isEmpty(val)) { val = defaultText; } // Generate the text link if (StringUtil.isNotEmpty(val)) { writer.startElement("a", null); // $NON-NLS-1$ if(!renderLink) { //add a11y attributes writer.writeAttribute("aria-disabled", "true", null); // $NON-NLS-1$ $NON-NLS-2$ }else{ writer.writeAttribute("aria-disabled", "false", null); // $NON-NLS-1$ $NON-NLS-2$ writer.writeAttribute("href", "#", null); // $NON-NLS-1$ $NON-NLS-2$ } String pagerLinkClass = (String)getProperty(PROP_PAGERLINKCLASS); if(StringUtil.isNotEmpty(pagerLinkClass)) { writer.writeAttribute("class", pagerLinkClass, null); // $NON-NLS-1$ } writer.writeAttribute("id", controlId + "__lnk", null); // $NON-NLS-1$ $NON-NLS-2$ writer.writeAttribute("role", "button", null); // $NON-NLS-1$ $NON-NLS-2$ writer.writeAttribute("aria-label", ariaLabel, null); // $NON-NLS-1$ writer.writeText(val, null); writer.endElement("a"); // $NON-NLS-1$ if (renderLink) { setupSubmitOnClick(context, pager, st, controlId, controlId + "__lnk"); // $NON-NLS-1$ } } writer.endElement("li"); // $NON-NLS-1$ }
Example 15
Source File: TabViewRenderer.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
/** * This methods generates the HTML code of the current b:tabView. * * @param context * the FacesContext. * @param component * the current b:tabView. * @throws IOException * thrown if something goes wrong when writing the HTML code. */ @Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { assertComponentIsInsideForm(component, "The initially opened tab is opened after an post-back request, regardless which tab has been previously activated by the user"); if (!component.isRendered()) { return; } TabView tabView = (TabView) component; ResponseWriter writer = context.getResponseWriter(); String clientId = tabView.getClientId(); if (!tabView.isRendered()) { return; } writer.startElement("input", tabView); writer.writeAttribute("type", "hidden", null); final String hiddenInputFieldID = clientId.replace(":", "_") + "_activeIndex"; writer.writeAttribute("name", hiddenInputFieldID, "name"); writer.writeAttribute("id", hiddenInputFieldID, "id"); writer.writeAttribute("value", "", "value"); writer.endElement("input"); // set tab directions final String tabPosition = tabView.getTabPosition(); String wrapperClass = "tab-panel"; if ("bottom".equalsIgnoreCase(tabPosition)) wrapperClass += " tabs-below"; writer.startElement("div", tabView); writer.writeAttribute("class", wrapperClass, "class"); writer.writeAttribute("role", "tabpanel", "class"); writer.writeAttribute("dir", tabView.getDir(), "dir"); final List<UIComponent> tabs = getTabs(tabView); int activeIndex = forceActiveTabToBeEnabled(tabView, tabs); if ("bottom".equalsIgnoreCase(tabPosition)) { encodeTabContentPanes(context, writer, tabView, activeIndex, tabs); encodeTabLinks(context, writer, tabView, activeIndex, tabs, clientId, hiddenInputFieldID); } else if ("left".equalsIgnoreCase(tabPosition)) { writer.startElement("div", component); writer.writeAttribute("class", "col-md-2", "class"); encodeTabLinks(context, writer, tabView, activeIndex, tabs, clientId, hiddenInputFieldID); writer.endElement("div"); writer.startElement("div", component); writer.writeAttribute("class", "col-md-10", "class"); encodeTabContentPanes(context, writer, tabView, activeIndex, tabs); writer.endElement("div"); drawClearDiv(writer, tabView); } else if ("right".equalsIgnoreCase(tabPosition)) { writer.startElement("div", component); writer.writeAttribute("class", "col-md-10", "class"); encodeTabContentPanes(context, writer, tabView, activeIndex, tabs); writer.endElement("div"); writer.startElement("div", component); writer.writeAttribute("class", "col-md-2", "class"); encodeTabLinks(context, writer, tabView, activeIndex, tabs, clientId, hiddenInputFieldID); writer.endElement("div"); drawClearDiv(writer, tabView); } else { encodeTabLinks(context, writer, tabView, activeIndex, tabs, clientId, hiddenInputFieldID); encodeTabContentPanes(context, writer, tabView, activeIndex, tabs); } writer.endElement("div"); Map<String, String> eventHandlers = new HashMap<String, String>(); eventHandlers.put("shown","if(typeof PrimeFaces != 'undefined'){PrimeFaces.invokeDeferredRenders('" + clientId + "_content');}"); new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForJQuery(context, component, writer, "#" + clientId + " > li > a[data-toggle=\"tab\"]", eventHandlers); Tooltip.activateTooltips(context, tabView); }
Example 16
Source File: MobileFormTableRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
@Override protected void writeMultiColumnRows(FacesContext context, ResponseWriter w, FormLayout c, UIComponent parent, ComputedFormData formData) throws IOException { List<UIComponent> children = TypedUtil.getChildren(parent); boolean li = false;//this is to keep track of the row we are in and make sure we do not leave a row open at the end of renderering String style = ""; // $NON-NLS-1$ for(UIComponent child: children) { if(!child.isRendered()) { continue; } if(child instanceof UIFormLayoutRow) { //should just be a li if(li) { w.endElement("li"); // $NON-NLS-1$ } newLine(w); w.startElement("li", c); //$NON-NLS-1$ style = (String)getProperty(PROP_MULTICOLUMNFORMLAYOUTROWTABLESTYLE); if ( StringUtil.isNotEmpty(style) ) { w.writeAttribute("style", style, null); // $NON-NLS-1$ } writeFormRow(context, w, c, formData, (UIFormLayoutRow)child); w.endElement("li"); //$NON-NLS-1$ newLine(w); li = false; } else if(child instanceof UIFormLayoutColumn) { //each column is a new list UIFormLayoutColumn col = (UIFormLayoutColumn)child; if(!li) { w.startElement("li", c); // $NON-NLS-1$ String colStyle = col.getStyle(); if(StringUtil.isNotEmpty(colStyle)) { w.writeAttribute("style", colStyle, null); // $NON-NLS-1$ } String colClass = (String)getProperty(PROP_MULTICOLUMNROWSTYLECLASS); if(StringUtil.isNotEmpty(colClass)) { w.writeAttribute("class", colClass, null); // $NON-NLS-1$ } li = true; } w.startElement("ul", c); //$NON-NLS-1$ style = (String)getProperty(PROP_MULTICOLUMNFORMLAYOUTCOLUMNTABLESTYLE); if ( StringUtil.isNotEmpty(style) ) { w.writeAttribute("style", style, null); // $NON-NLS-1$ } for(UIComponent row: TypedUtil.getChildren(col)) { if(row instanceof UIFormLayoutRow) { if(!row.isRendered()) { continue; } writeFormRow(context, w, c, formData, (UIFormLayoutRow)row); } } w.endElement("ul"); //$NON-NLS-1$ newLine(w); } else { if( !(child instanceof FormLayout) ){ writeChildRows(context, w, c, child, formData); }// do not recurse through FormLayout descendants } } if(li) { w.endElement("li"); //$NON-NLS-1$ newLine(w); } newLine(w); }
Example 17
Source File: LabelRenderer.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
/** * label methods generates the HTML code of the current b:label. * @param context the FacesContext. * @param component the current b:label. * @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; } Label label = (Label) component; ResponseWriter rw = context.getResponseWriter(); String clientId = label.getClientId(); boolean idHasBeenRendered = false; String sev = label.getSeverity(); String txt = label.getValue(); if (txt == null) { txt = label.getText(); } // add responsive style String clazz = Responsive.getResponsiveStyleClass(label, false).trim(); boolean isResponsive = clazz.length() > 0; if (isResponsive) { rw.startElement("div", label); rw.writeAttribute("class", clazz, null); rw.writeAttribute("id", clientId, "id"); idHasBeenRendered = true; } rw.startElement("span", label); if (!idHasBeenRendered) { rw.writeAttribute("id", clientId, "id"); } Tooltip.generateTooltip(context, label, rw); String sclass = "label" + " " + "label"; if (sev != null) { sclass += "-" + sev; } else { sclass += "-default"; } String styleClass = label.getStyleClass(); sclass += styleClass != null ? " " + styleClass : ""; rw.writeAttribute("class", sclass, "class"); String style = label.getStyle(); if (isResponsive) { if (null == style) { style = "display:block"; } else { style += ";display:block"; } } if (style != null) rw.writeAttribute("style", style, "style"); rw.writeText(txt, null); rw.endElement("span"); if (isResponsive) { rw.endElement("div"); } Tooltip.activateTooltips(context, label); }
Example 18
Source File: RadioGroupRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
@Override protected void renderBeginText(UIComponent component, int border, boolean alignVertical, FacesContext context, boolean outer) throws IOException { XspSelectOneRadio radioGroup = (component instanceof XspSelectOneRadio) ? (XspSelectOneRadio)component : null; if (null != radioGroup) { ResponseWriter writer = context.getResponseWriter(); String accesskey = radioGroup.getAccesskey(); String dir = radioGroup.getDir(); String lang = radioGroup.getLang(); String role = radioGroup.getRole(); String style = radioGroup.getStyle(); String styleClass = radioGroup.getStyleClass(); String title = radioGroup.getTitle(); String legend = radioGroup.getLegend(); writer.startElement("div", component); // $NON-NLS-1$ //dojoType and dojoAttributes if they are present DojoUtil.addDojoAttributes(context, radioGroup); // for SPR#MKEE89GMU5, always output fieldset id, so it can be compared // to the name attribute of the inner input controls. String clientId = radioGroup.getClientId(FacesContext.getCurrentInstance()); if (clientId != null ) { writer.writeAttribute("id", clientId, "id"); //$NON-NLS-1$ //$NON-NLS-2$ } if (StringUtil.isNotEmpty(accesskey)) { writer.writeAttribute("accesskey", accesskey, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(dir)) { writer.writeAttribute("dir", dir, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(lang)) { writer.writeAttribute("lang", lang, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(role)) { writer.writeAttribute("role", role, null); // $NON-NLS-1$ } if (radioGroup.isRequired()) { writer.writeAttribute("aria-required", "true", null); // $NON-NLS-1$ $NON-NLS-2$ } if (!radioGroup.isValid()) { writer.writeAttribute("aria-invalid", "true", null); // $NON-NLS-1$ $NON-NLS-2$ } if (StringUtil.isNotEmpty(style)) { writer.writeAttribute("style", style, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(styleClass)) { writer.writeAttribute("class", styleClass, null); // $NON-NLS-1$ } String onchangeTrigger = null; if( context instanceof FacesContextEx ){ FacesContextEx contextEx = (FacesContextEx)context; //xsp.client.script.radioCheckbox.ie.onchange.trigger= early-onclick | late-onblur[default] onchangeTrigger = contextEx.getProperty(XspPropertyConstants.XSP_RADIO_ONCHANGE_TRIGGER); } if( null != onchangeTrigger && !"late-onblur".equals(onchangeTrigger) ){ //$NON-NLS-1$ writer.writeAttribute("onchangeTrigger", onchangeTrigger, null); //$NON-NLS-1$ } if (component instanceof FacesAttrsObject) { FacesAttrsObject attrsHolder = (FacesAttrsObject) component; AttrsUtil.encodeAttrs(context, writer, attrsHolder); } writer.startElement("table", component); // $NON-NLS-1$ writer.writeAttribute("role", "presentation", null); //$NON-NLS-1$ //$NON-NLS-2$ if (Integer.MIN_VALUE != border) { writer.writeAttribute("border", Integer.toString(border), "border"); //$NON-NLS-1$ //$NON-NLS-2$ } if (StringUtil.isNotEmpty(title)) { writer.writeAttribute("title", title, null); // $NON-NLS-1$ } writer.writeText("\n", null); // $NON-NLS-1$ if (StringUtil.isNotEmpty(legend)) { writer.startElement("caption", component); // $NON-NLS-1$ if (StringUtil.isNotEmpty(dir)) { writer.writeAttribute("dir", dir, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(lang)) { writer.writeAttribute("lang", lang, null); // $NON-NLS-1$ } writer.writeAttribute("class", "xspGroupCaption", null); // $NON-NLS-1$ $NON-NLS-2$ writer.writeText(legend, "legend"); // $NON-NLS-1$ writer.endElement("caption"); // $NON-NLS-1$ } if (!alignVertical) { writer.startElement("tr", component); // $NON-NLS-1$ writer.writeText("\n", null); // $NON-NLS-1$ } } }
Example 19
Source File: TimerBarRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
/** * <p>Faces render output method .</p> * <p>Method Generator: org.sakaiproject.tool.assessment.devtools.RenderMaker</p> * * @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"); } }
Example 20
Source File: SelectManyCheckboxListRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public void renderBeginText(UIComponent component, int border, boolean alignVertical, FacesContext context) throws IOException { XspSelectManyCheckbox checkboxGroup = (component instanceof XspSelectManyCheckbox) ? (XspSelectManyCheckbox)component : null; if (null != checkboxGroup) { ResponseWriter writer = context.getResponseWriter(); String accesskey = checkboxGroup.getAccesskey(); String dir = checkboxGroup.getDir(); String lang = checkboxGroup.getLang(); String role = checkboxGroup.getRole(); String style = checkboxGroup.getStyle(); String styleClass = checkboxGroup.getStyleClass(); String title = checkboxGroup.getTitle(); String legend = checkboxGroup.getLegend(); //Start the containing div for the checkbox group writer.startElement("div", component); // $NON-NLS-1$ if(checkboxGroup.getDojoType()==null) { writer.writeAttribute("class", "checkbox", "class"); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$ }else{ writer.writeAttribute("style", "display: inline;", "style"); // $NON-NLS-2$ $NON-NLS-1$ $NON-NLS-3$ } //dojoType and dojoAttributes if they are present DojoUtil.addDojoAttributes(context, checkboxGroup); String clientId = checkboxGroup.getClientId(context); if (null != clientId) { writer.writeAttribute("id", clientId, "id"); //$NON-NLS-1$ //$NON-NLS-2$ } if (StringUtil.isNotEmpty(accesskey)) { writer.writeAttribute("accesskey", accesskey, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(dir)) { writer.writeAttribute("dir", dir, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(lang)) { writer.writeAttribute("lang", lang, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(role)) { writer.writeAttribute("role", role, null); // $NON-NLS-1$ } if (checkboxGroup.isRequired()) { writer.writeAttribute("aria-required", "true", null); // $NON-NLS-1$ $NON-NLS-2$ } if (!checkboxGroup.isValid()) { writer.writeAttribute("aria-invalid", "true", null); // $NON-NLS-1$ $NON-NLS-2$ } if (StringUtil.isNotEmpty(style)) { writer.writeAttribute("style", style, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(styleClass)) { writer.writeAttribute("class", styleClass, null); // $NON-NLS-1$ } String onchangeTrigger = null; if( context instanceof FacesContextEx ){ FacesContextEx contextEx = (FacesContextEx)context; //xsp.client.script.radioCheckbox.ie.onchange.trigger= early-onclick | late-onblur[default] onchangeTrigger = contextEx.getProperty(XspPropertyConstants.XSP_RADIO_ONCHANGE_TRIGGER); } if( null != onchangeTrigger && !"late-onblur".equals(onchangeTrigger) ){ //$NON-NLS-1$ writer.writeAttribute("onchangeTrigger", onchangeTrigger, null); //$NON-NLS-1$ } AttrsUtil.encodeAttrs(context, writer, checkboxGroup); writer.startElement("table", component); // $NON-NLS-1$ writer.writeAttribute("role", "presentation", null); //$NON-NLS-1$ //$NON-NLS-2$ if (StringUtil.isNotEmpty(role)) { writer.writeAttribute("title", title, null); // $NON-NLS-1$ } if (Integer.MIN_VALUE != border) { writer.writeAttribute("border", Integer.toString(border), "border"); //$NON-NLS-1$ //$NON-NLS-2$ } writer.writeText("\n", null); // $NON-NLS-1$ if (StringUtil.isNotEmpty(legend)) { writer.startElement("caption", component); // $NON-NLS-1$ if (StringUtil.isNotEmpty(dir)) { writer.writeAttribute("dir", dir, null); // $NON-NLS-1$ } if (StringUtil.isNotEmpty(lang)) { writer.writeAttribute("lang", lang, null); // $NON-NLS-1$ } writer.writeAttribute("class", "xspGroupCaption", null); // $NON-NLS-2$ $NON-NLS-1$ writer.writeText(legend, "legend"); // $NON-NLS-1$ writer.endElement("caption"); // $NON-NLS-1$ } if (!alignVertical) { writer.startElement("tr", component); // $NON-NLS-1$ writer.writeText("\n", null); // $NON-NLS-1$ } } }