Java Code Examples for javax.faces.context.ResponseWriter#append()
The following examples show how to use
javax.faces.context.ResponseWriter#append() .
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: AutoCloseMessages.java From library with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * @param context * @param component * @throws IOException */ @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { super.encodeEnd(context, component); final ResponseWriter writer = context.getResponseWriter(); writer.write('\n'); writer.startElement("script", null); writer.writeText("setTimeout(\"$(\'#" + this.sanitizeId(component.getClientId()) + "\').slideUp(500)\", 8000)", null); writer.endElement("script"); writer.append('\r'); writer.append('\n'); }
Example 2
Source File: AutoCloseMessages.java From web-budget with GNU General Public License v3.0 | 6 votes |
/** * {@inheritDoc} * * @param context * @param component * @throws IOException */ @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { super.encodeEnd(context, component); final ResponseWriter writer = context.getResponseWriter(); writer.write('\n'); writer.startElement("script", null); writer.writeText("setTimeout(\"$(\'#" + this.sanitizeId(component.getClientId()) + "\').slideUp(500)\", 8000)", null); writer.endElement("script"); writer.append('\r'); writer.append('\n'); }
Example 3
Source File: InternalFALink.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
@Override public void encodeBegin(FacesContext fc) throws IOException { final String FA_VERSION = "4.7.0"; final String FONTAWESOME_CDN_URL = "//maxcdn.bootstrapcdn.com/font-awesome/" + FA_VERSION + "/css/font-awesome.min.css"; ResponseWriter responseWriter = fc.getResponseWriter(); LOGGER.log(Level.FINER, "do encodeBegin - version is {0} / needsVersion4 is {1}", new Object[] { version, needsVersion4 }); if (version.contains("5")) { responseWriter.append( "<link type=\"text/css\" rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v5.2.0/css/all.css\" crossorigin=\"anonymous\"/>"); responseWriter.append( "<link type=\"text/css\" rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v5.2.0/css/solid.css\" crossorigin=\"anonymous\"/>"); } if (version.contains("4")) { if (needsVersion4) { responseWriter.append("<link type=\"text/css\" rel=\"stylesheet\" href=\"" + FONTAWESOME_CDN_URL + "\" crossorigin=\"anonymous\"/>"); } } }
Example 4
Source File: AutoCloseMessages.java From web-budget with GNU General Public License v3.0 | 6 votes |
/** * {@inheritDoc} * * @param context * @param component * @throws IOException */ @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { super.encodeEnd(context, component); final ResponseWriter writer = context.getResponseWriter(); writer.write('\n'); writer.startElement("script", null); writer.writeText("setTimeout(\"$(\'#" + this.sanitizeId(component.getClientId()) + "\').slideUp(500)\", 8000)", null); writer.endElement("script"); writer.append('\r'); writer.append('\n'); }
Example 5
Source File: Poll.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
@Override public void encodeEnd(FacesContext context) throws IOException { if (!isRendered()) { return; } String id = getClientId(); String widgetVarName = getWidgetVar() == null ? BsfUtils.widgetVarName(id) : getWidgetVar(); String intervalId = "window." + BsfUtils.javaScriptVarName(id); String update = ExpressionResolver.getComponentIDs(context, this, getUpdate()); String execute = ExpressionResolver.getComponentIDs(context, this, getExecute()); ResponseWriter rw = context.getResponseWriter(); rw.append("<script id='" + id + "' type='text/javascript'>\r\n"); if (isStop()) { rw.append("clearInterval(" + intervalId + ");\r\n"); } else { rw.append(widgetVarName + " = new function(){\r\n"); rw.append("var o = this;\r\n"); rw.append("var handleError = function(){ o.stop(); console.log('error with b:poll " + id + "');};\r\n"); rw.append("this.start = function(){ o.stop(); " + intervalId + " = setInterval(function(){ "); rw.append("jsf.ajax.request('" + id + "', null, {'" + id + "':'" + id + "', execute:'" + execute + "', render:'" + update + "', onerror:handleError }); }, " + getInterval() + "); };\r\n"); rw.append("this.stop = function(){ clearInterval(" + intervalId + "); };\r\n"); rw.append("this.start();\r\n"); rw.append("}();\r\n"); } rw.append("</script>"); }
Example 6
Source File: RemoteCommandRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * This methods generates the HTML code of the current b:remoteCommand. * @param context the FacesContext. * @param component the current b:remoteCommand. * @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; } RemoteCommand remoteCommand = (RemoteCommand) component; ResponseWriter rw = context.getResponseWriter(); String clientId = remoteCommand.getClientId(); String parameters=remoteCommand.getParameters(); String parametersAsJson=null; if (null != parameters && parameters.length()>0) { parametersAsJson = ""; String[] params = parameters.split(","); for (String p: params) { p=p.trim(); parametersAsJson += "'" + p + "':" + p + ","; } parametersAsJson=parametersAsJson.substring(0, parametersAsJson.length()-1); } StringBuilder call = AJAXRenderer.generateAJAXCall(context, remoteCommand, null, parametersAsJson); String name = remoteCommand.getName(); if (null == name) { throw new FacesException("b:remoteCommand: Please define the name of the JavaScript function calling the Java backend."); } rw.startElement("script", component); rw.writeAttribute("id", clientId, null); String c = call.toString().replace("callAjax(this,", "callAjax(document.getElementById('" + clientId + "'),"); if (parameters!=null) { rw.append("function " + name + "(" + parameters + ", event){" + c + "}"); } else { rw.append("function " + name + "(event){" + c + "}"); } rw.endElement("script"); }
Example 7
Source File: SelectBooleanCheckboxRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Closes the input tag. This method is protected in order to allow * third-party frameworks to derive from it. * * @param rw * the response writer * @param selectBooleanCheckbox * the component to render * @throws IOException * may be thrown by the response writer */ protected void renderInputTagEnd(ResponseWriter rw, SelectBooleanCheckbox selectBooleanCheckbox) throws IOException { rw.endElement("input"); String caption = selectBooleanCheckbox.getCaption(); if (null != caption) { if (selectBooleanCheckbox.isEscape()) { rw.writeText(" " + caption, null); } else { rw.append(" " + caption); } } rw.endElement("label"); rw.endElement("div"); }
Example 8
Source File: SwitchRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter rw = context.getResponseWriter(); String clientId = component.getClientId(); super.encodeBegin(context, component); clientId = clientId.replace(":", "\\\\:"); rw.append("<script>"); rw.append("$('#input_" + clientId + "').bootstrapSwitch();"); rw.append("</script>"); }
Example 9
Source File: CarouselCaptionRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
public void encodeDefaultCaption(FacesContext context, UIComponent component, String caption) throws IOException { encodeBegin(context, component); ResponseWriter rw = context.getResponseWriter(); rw.startElement("h3", component); rw.append(caption); rw.endElement("h3"); encodeEnd(context, component); }
Example 10
Source File: CarouselControlRenderer.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
public void encodeDefaultControls(FacesContext context, UIComponent component, String clientId) throws IOException { ResponseWriter rw = context.getResponseWriter(); { rw.startElement("a", component); rw.writeAttribute("class", "left carousel-control", "class"); rw.writeAttribute("href", "#"+clientId, "href"); rw.writeAttribute("role", "button", "role"); rw.writeAttribute("data-slide", "prev", "data-slide"); { rw.startElement("span", component); rw.writeAttribute("class", "glyphicon glyphicon-chevron-left", "class"); rw.writeAttribute("aria-hidden", "true", "aria-hidden"); rw.endElement("span"); } { rw.startElement("span", component); rw.writeAttribute("class", "sr-only", "class"); rw.append("Previous"); rw.endElement("span"); } rw.endElement("a"); } { rw.startElement("a", component); rw.writeAttribute("class", "right carousel-control", "class"); rw.writeAttribute("href", "#"+clientId, "href"); rw.writeAttribute("role", "button", "role"); rw.writeAttribute("data-slide", "next", "data-slide"); { rw.startElement("span", component); rw.writeAttribute("class", "glyphicon glyphicon-chevron-right", "class"); rw.writeAttribute("aria-hidden", "true", "aria-hidden"); rw.endElement("span"); } { rw.startElement("span", component); rw.writeAttribute("class", "sr-only", "class"); rw.append("Next"); rw.endElement("span"); } rw.endElement("a"); } }