Java Code Examples for javax.faces.context.FacesContext#getResponseWriter()
The following examples show how to use
javax.faces.context.FacesContext#getResponseWriter() .
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: UICommandLink.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void encodeBegin(FacesContext context) throws IOException { JsfRenderUtils.addEventHandlingHiddenFieldsIfNotExists(context, this); List<UIParameter> uiParameters = getParametersWithNameAttribute(); JsfRenderUtils.addHiddenFieldsForParametersIfNotExists(context, this, uiParameters); ResponseWriter writer = context.getResponseWriter(); writer.startElement("a", this); writer.writeAttribute("type", (this.getType() != null) ? this.getType() : "", null); writer.writeAttribute("title", (this.getTitle() != null) ? this.getTitle() : "", null); if (this.getTarget() != null) { writer.writeAttribute("target", this.getTarget(), null); } writer.writeAttribute("onclick", getOnClickEvent(context, uiParameters), null); writer.writeAttribute("href", "#", null); writer.writeAttribute("id", getClientId(context), null); writer.writeAttribute("name", getClientId(context), null); writer.writeAttribute("style", (this.getStyle() != null) ? this.getStyle() : "", null); writer.writeAttribute("class", (this.getStyleClass() != null) ? this.getStyleClass() : "", null); writer.writeText(this.getValue(), null); }
Example 2
Source File: HierDataTableRender.java From sakai with Educational Community License v2.0 | 6 votes |
public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if ((context == null) || (component == null)) { throw new IllegalArgumentException(MessageUtils.getExceptionMessageString(MessageUtils.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()); } }
Example 3
Source File: PopupRenderer.java From sakai with Educational Community License v2.0 | 6 votes |
/** * <p>Render end of ANCHOR.</p> * * @param context FacesContext for the request we are processing * @param component UIComponent to be rendered * * @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 buttonSwitch = (String) RendererUtil.getAttribute(context, component, "useButton"); boolean useButton = Boolean.getBoolean( RendererUtil.makeSwitchString(buttonSwitch, false, true, true, false, false, false)); if (!useButton) { writer.write("</a>"); } }
Example 4
Source File: WidgetContainerRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { UIWidgetContainer container = (UIWidgetContainer)component; if(!container.isRendered()) { return; } ResponseWriter w = context.getResponseWriter(); writeMainFrame(context, w, container); }
Example 5
Source File: UploadRenderer.java From sakai with Educational Community License v2.0 | 5 votes |
public void encodeBegin(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) return; ResponseWriter writer = context.getResponseWriter(); ExternalContext external = context.getExternalContext(); HttpServletRequest request = (HttpServletRequest) external.getRequest(); String clientId = component.getClientId(context); log.debug("** encodeBegin, clientId = {}", clientId); encodeUploadField(writer, clientId, component); }
Example 6
Source File: AbstractOutlineRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); if( AjaxUtil.isAjaxNullResponseWriter(writer) ) { return; } AbstractOutline outline = (AbstractOutline)component; render(context, outline, writer); }
Example 7
Source File: AbstractDataViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void encodeRows(FacesContext context, UIDataIterator iterator, int first, int rows) throws IOException { ResponseWriter w = context.getResponseWriter(); AbstractDataView c = (AbstractDataView)iterator; ViewDefinition viewDef = createViewDefinition(context); initViewDefinition(context, c, viewDef); writeRows(context, w, c, viewDef, first, rows); }
Example 8
Source File: FormGroupRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } ResponseWriter rw = context.getResponseWriter(); endDisabledFieldset((IContentDisabled) component, rw); rw.endElement("div"); }
Example 9
Source File: SeparatorRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter w = context.getResponseWriter(); boolean rendered = component.isRendered(); if(!rendered) { return; } writeSeparator(context, w, (UISeparator)component); }
Example 10
Source File: TreeRenderer.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } Tree tree = (Tree) component; String clientId = tree.getClientId(); String jqClientId = BsfUtils.escapeJQuerySpecialCharsInSelector(clientId); ResponseWriter rw = context.getResponseWriter(); final UIForm form = BsfUtils.getClosestForm(tree); if (form == null) { throw new FacesException("The tree component must be inside a form", null); } // String updateItems = BsfUtils.GetOrDefault("'" + tree.getUpdate() + "'", "null"); String updateItems = tree.getUpdate(); if (updateItems != null) { updateItems = ExpressionResolver.getComponentIDs(context, component, updateItems); } rw.startElement("script", tree); //# Start enclosure rw.writeText("$(document).ready(function() {", null); // build tree management javascript rw.writeText("function getTreeData() { " + " return '" + TreeModelUtils.renderModelAsJson(tree.getValue(), tree.isRenderRoot()) + "'; " + "} " + // build tree structure "$('#tree_" + jqClientId + "').treeview({ " + (tree.isShowTags() ? "showTags: true," : "") + (tree.isShowIcon() ? "showIcon: true," : "") + (tree.isShowCheckbox() ? "showCheckbox: true," : "") + (tree.isEnableLinks() ? "enableLinks: true," : "") + (tree.isShowBorder() ? "showBorder: true," : "showBorder: false,") + (BsfUtils.isStringValued(tree.getCollapseIcon()) ? "collapseIcon: '" + tree.getCollapseIcon() + "'," : "") + (BsfUtils.isStringValued(tree.getExpandIcon()) ? "expandIcon: '" + tree.getExpandIcon() + "'," : "") + (BsfUtils.isStringValued(tree.getColor()) ? "color: '" + tree.getColor() + "'," : "") + (BsfUtils.isStringValued(tree.getHoverColor()) ? "onhoverColor: '" + tree.getHoverColor() + "'," : "") + (BsfUtils.isStringValued(tree.getSelectedColor()) ? "selectedColor: '" + tree.getSelectedColor() + "'," : "") + (BsfUtils.isStringValued(tree.getBorderColor()) ? "borderColor: '" + tree.getBorderColor() + "'," : "") + " data: getTreeData(), " + // enable nodeSelected event callback " onNodeSelected: function(event, data) { " + " BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeSelected:' + data.nodeInternalId);" + " }," + // enable nodeUnselected event callback " onNodeUnselected: function(event, data) { " + " BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeUnselected:' + data.nodeInternalId);" + " }," + //enable nodeChecked event callback " onNodeChecked: function(event, data) { " + " BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeChecked:' + data.nodeInternalId);" + " }," + //enable nodeUnchecked event callback " onNodeUnchecked: function(event, data) { " + " BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeUnchecked:' + data.nodeInternalId);" + " }," + // enable nodeCollapsed event callback " onNodeCollapsed: function(event, data) { " + " BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeCollapsed:' + data.nodeInternalId);" + " }," + // enable nodeExpanded event callback " onNodeExpanded: function(event, data) { " + " BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeExpanded:' + data.nodeInternalId);" + // @all " }" + "}); ", null); rw.writeText("});", null); rw.endElement("script"); }
Example 11
Source File: DataLineRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
/** * We put all our processing in the encodeChildren method * @param context * @param component * @throws IOException */ public void encodeChildren(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } String clientId = null; if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) { clientId = component.getClientId(context); } ResponseWriter writer = context.getResponseWriter(); if (clientId != null) { writer.startElement("span", component); writer.writeAttribute("id", clientId, "id"); } UIData data = (UIData) component; int first = data.getFirst(); int rows = data.getRows(); // this is a special separator attribute, not supported by UIData String separator = (String) component.getAttributes().get("separator"); if (separator==null) separator=""; for (int i = first, n = 0; n < rows; i++, n++) { data.setRowIndex(i); if (!data.isRowAvailable()) { break; } // between any two iterations add separator if there is one if (i!=first) writer.write(separator); Iterator iter = data.getChildren().iterator(); while (iter.hasNext()) { UIComponent column = (UIComponent) iter.next(); if (!(column instanceof UIColumn)) { continue; } RendererUtil.encodeRecursive(context, column); } } if (clientId != null) { writer.endElement("span"); } }
Example 12
Source File: SeparatedListRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
/** * We put all our processing in the encodeChildren method * @param context * @param component * @throws IOException */ public void encodeChildren(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } String clientId = null; if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) { clientId = component.getClientId(context); } ResponseWriter writer = context.getResponseWriter(); if (clientId != null) { String styleClass = (String) RendererUtil.getAttribute(context, component, "styleClass"); writer.startElement("div", component); writer.writeAttribute("id", clientId, "id"); writer.writeAttribute("class", styleClass, "class"); } List children = component.getChildren(); // this is a special separator attribute, not supported by UIData String separator = (String) RendererUtil.getAttribute(context, component, "separator"); if (separator==null) separator=" | "; boolean first = true; for (Iterator iter = children.iterator(); iter.hasNext();) { UIComponent child = (UIComponent)iter.next(); if (child.isRendered()) { if (!first) writer.write(separator); RendererUtil.encodeRecursive(context, child); first = false; } } if (clientId != null) { writer.endElement("div"); } }
Example 13
Source File: DojoContentPaneRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Integer mode = (Integer) HtmlUtil.readEncodeParameter(context, component); // // Script handling // The refresh is not done through a regular partialRefresh code from // the XPages JS library, but through standard dojo code. // Because of this, the <script> tags emitted by the ScriptCollector are // not properly executed, because XSP.addOnLoad() requires // a call to XSP._loaded(). // More then that, the scripts are in fact only loaded on FireFox when // dynamically inserted into the DOM. To detect if they have // been loaded (executed) or not, we use the '_cpOnLoadScript' flag. // All of this is done in the 'XSP._cpOnLoad' function. To ensure that // it is called once the panel content is loaded, we define // a handler on the onLoad event. And because the script are not loaded // in some browsers, we cannot emit a dojo.connect() JS // statement, but we use a dojo/connect markup piece. // if (mode == AJXCONTENT) { // We are refreshing the content of the panel // We set the flag that defines if the script had been loaded UIScriptCollector c = UIScriptCollector.find(); c.addScript("XSP._cpOnLoadScript=true"); // $NON-NLS-1$ } if (mode == FRAME) { ExtLibResources.addEncodeResource((UIViewRootEx) context .getViewRoot(), ExtLibResources.extlibExtLib); // When we only emit the tag of the content pane, we define an event // handler on onLoad() // to ensure that the script are properly loaded, and XSP._loaded() // called once the panel // is ready. ResponseWriter w = context.getResponseWriter(); w.startElement("script", null); // $NON-NLS-1$ w.writeAttribute("type", "dojo/connect", null); // $NON-NLS-1$ $NON-NLS-2$ w.writeAttribute("event", "onLoad", null); // $NON-NLS-1$ $NON-NLS-2$ StringBuilder b = new StringBuilder(); b.append("XSP._cpOnLoad("); // $NON-NLS-1$ JavaScriptUtil.addString(b, component.getClientId(context)); b.append(");"); //$NON-NLS-1$ w.write(b.toString()); w.endElement("script"); // $NON-NLS-1$ } if ((mode == FULL) || (mode == FRAME)) { super.encodeEnd(context, component); newLine(context.getResponseWriter()); } HtmlUtil.removeEncodeParameter(context, component); }
Example 14
Source File: ApplicationRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { UIApplication appPageContainer = (UIApplication)component; UIViewRootEx rootEx = (UIViewRootEx)context.getViewRoot(); String themeName = ((FacesContextEx)context).getStyleKit().getName(); StyleSheetResource[] styleSheets = {}; if(themeName.equals(ANDROID_THEME_NAME)){ styleSheets = ANDROID_STYLE_SHEETS; } else if(themeName.equals(BLACKBERRY_THEME_NAME)){ styleSheets = BLACKBERRY_STYLE_SHEETS; } else if(themeName.equals(IPHONE_THEME_NAME)){ styleSheets = IPHONE_STYLE_SHEETS; } else { // don't provide the resources at this level but instead let the *.theme provide them // ... this ensures correct ordering determined by the theme resource order styleSheets = new StyleSheetResource[] {}; } for(StyleSheetResource css : styleSheets){ ExtLibResources.addEncodeResource(rootEx, css); } ResponseWriter w = context.getResponseWriter(); w.startElement("div", null); // $NON-NLS-1$ String dojoType = getDojoType(); if(StringUtil.isEmpty(dojoType)) { throw new IllegalStateException(); } // always write the ID, so any event listeners will work w.writeAttribute("id", appPageContainer.getClientId(context), null); //$NON-NLS-1$ w.writeAttribute("dojoType", dojoType, "dojoType"); // $NON-NLS-1$ $NON-NLS-2$ w.writeAttribute("class", "singlePageApp", "class"); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$ w.writeAttribute("selectedAppPage",appPageContainer.getSelectedPageName(),"selectedAppPage"); // $NON-NLS-1$ $NON-NLS-2$ String onOrientationChange = appPageContainer.getOnOrientationChange(); if( null != onOrientationChange ){ w.writeAttribute("onOrientationChange", onOrientationChange, "onOrientationChange"); //$NON-NLS-1$ //$NON-NLS-2$ } String onResize = appPageContainer.getOnResize(); if( null != onResize ){ w.writeAttribute("onResize", onResize, "onResize"); //$NON-NLS-1$ //$NON-NLS-2$ } w.endElement("div"); // $NON-NLS-1$ JSUtil.writeln(w); }
Example 15
Source File: LineRenderer.java From ChartistJSF with Apache License 2.0 | 4 votes |
@Override protected void encodeOptions(FacesContext context, Chart chart) throws IOException { super.encodeOptions(context, chart); ResponseWriter writer = context.getResponseWriter(); LineChartModel model = (LineChartModel) chart.getModel(); writer.write(",animateAdvanced:" + model.isAnimateAdvanced()); writer.write(",animatePath:" + model.isAnimatePath()); writer.write(",options:{"); for (Iterator<AxisType> it = model.getAxes().keySet().iterator(); it.hasNext();) { AxisType axisType = it.next(); Axis axis = model.getAxes().get(axisType); axis.render(writer, axisType); if (it.hasNext()) { writer.write(","); } } if (model.getWidth() != null) writer.write(",width:\"" + ComponentUtils.escapeText(model.getWidth()) + "\""); if (model.getHeight() != null) writer.write(",height:\"" + ComponentUtils.escapeText(model.getHeight()) + "\""); writer.write(",showLine:" + model.isShowLine()); writer.write(",showPoint:" + model.isShowPoint()); writer.write(",showArea:" + model.isShowArea()); writer.write(",areaBase:" + model.getAreaBase()); writer.write(",lineSmooth:" + model.isLineSmooth()); writer.write(",showGridBackground:" + model.isShowGridBackground()); if (model.getLow() != 0) writer.write(",low:" + model.getLow()); if (model.getHigh() != 0) writer.write(",high:" + model.getHigh()); if (model.getChartPadding() != null) writer.write(",chartPadding:" + model.getChartPadding()); if (chart.getPlugins() != null) { writer.write(",plugins:" + chart.getPlugins()); } writer.write(",fullWidth:" + model.isFullWidth()); writer.write(",reverseData:" + model.isReverseData()); writer.write("}"); }
Example 16
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 3 votes |
/** * Renders a script that includes an external JavaScript that gets added to * the document through a document.write() if a gatekeeper value is NOT set. * This effectively makes the script inclusion a per request JavaScript * singleton. * * @param gateKey * for key value pair * @param gateValue * value for key value pair for gatekeeper * @param contextBasePath * the web app with the script * @param scriptPath * the webapp-relative path * @throws IOException */ public static void writeSmartExternalScripts(FacesContext context, String gateKey, String gateValue, String contextBasePath, String[] scriptPaths) throws IOException { ResponseWriter writer = context.getResponseWriter(); writeSmartExternalScripts(writer, gateKey, gateValue, contextBasePath, scriptPaths); }
Example 17
Source File: Datepicker.java From BootsFaces-OSP with Apache License 2.0 | 3 votes |
/** * Generates the default language for the date picker. Originally implemented in * the HeadRenderer, this code has been moved here to provide better * compatibility to PrimeFaces. If multiple date pickers are on the page, the * script is generated redundantly, but this shouldn't do no harm. * * @param fc * The current FacesContext * @throws IOException */ private void encodeDefaultLanguageJS(FacesContext fc) throws IOException { ResponseWriter rw = fc.getResponseWriter(); rw.startElement("script", null); rw.write("$.datepicker.setDefaults($.datepicker.regional['" + fc.getViewRoot().getLocale().getLanguage() + "']);"); rw.endElement("script"); }
Example 18
Source File: HideDivisionRenderer.java From sakai with Educational Community License v2.0 | 3 votes |
/** * <p>Faces render output method to output script tag.</p> * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</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 { ResponseWriter writer = context.getResponseWriter(); writer.write("</div>"); }
Example 19
Source File: DocSectionRenderer.java From sakai with Educational Community License v2.0 | 2 votes |
/** * @param context FacesContext for the request we are processing * @param component UIComponent to be rendered * @exception IOException if an input/output error occurs while rendering * @exception NullPointerException if <code>context</code> or <code>component</code> is null */ public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); writer.write("</p>"); }
Example 20
Source File: DocSectionRenderer.java From sakai with Educational Community License v2.0 | 2 votes |
/** * @param context FacesContext for the request we are processing * @param component UIComponent to be rendered * @exception IOException if an input/output error occurs while rendering * @exception NullPointerException if <code>context</code> or <code>component</code> is null */ public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); writer.write("</p>"); }