@Override public PartialResponseWriter getPartialResponseWriter() { if (writer == null) { PartialResponseWriter parentWriter = getWrapped().getPartialResponseWriter(); writer = new PrimePartialResponseWriter(parentWriter); } return writer; }
@Override public void endDocument() throws IOException { FacesContext context = FacesContext.getCurrentInstance(); PrimeRequestContext requestContext = PrimeRequestContext.getCurrentInstance(context); if (requestContext != null) { try { if (context.isValidationFailed()) { requestContext.getCallbackParams().put("validationFailed", true); } encodeCallbackParams(requestContext.getCallbackParams()); encodeScripts(requestContext); } catch (Exception e) { throw new AbortProcessingException(e); } } wrapped.endDocument(); }
startExtension(CALLBACK_EXTENSION_PARAMS); getWrapped().write("{"); encodeJSONValue(paramName, null); encodeJSONObject(paramName, (JSONObject) paramValue); encodeJSONArray(paramName, (JSONArray) paramValue); encodeJSONObject(paramName, new JSONObject(paramValue)); encodeJSONValue(paramName, paramValue); getWrapped().write(","); getWrapped().write("}"); endExtension();
protected void encodeScripts(PrimeRequestContext requestContext) throws IOException { List<String> scripts = requestContext.getScriptsToExecute(); if (!scripts.isEmpty()) { startEval(); for (int i = 0; i < scripts.size(); i++) { getWrapped().write(scripts.get(i)); getWrapped().write(';'); } endEval(); } }
encodeCallbackParams(params); ArrayList<ResourceUtils.ResourceInfo> currentResources = ResourceUtils.getComponentResources(context); if (initialResources != null && currentResources != null && currentResources.size() > initialResources.size()) { startEval(); getWrapped().write("if(window.PrimeFaces){"); getWrapped().write(script); if (scripts != null && !scripts.isEmpty()) { String script = "PrimeFaces.ajax.Utils.loadScripts(['" + CollectionUtils.join(scripts, "','") + "']);"; getWrapped().write(script); getWrapped().write("}"); endEval();
encodeCallbackParams(params); ResourceUtils.ResourceInfo resourceInfo = newResources.get(i); if (!updateStarted) { ((PartialResponseWriter) getWrapped()).startUpdate("javax.faces.Resource"); updateStarted = true; ((PartialResponseWriter) getWrapped()).endUpdate();
public void encodeJSONObject(String paramName, JSONObject jsonObject) throws IOException, JSONException { String json = jsonObject.toString(); json = EscapeUtils.forXml(json); getWrapped().write("\""); getWrapped().write(paramName); getWrapped().write("\":"); getWrapped().write(json); }
protected void encodeScripts(RequestContext requestContext) throws IOException { List<String> scripts = requestContext.getScriptsToExecute(); if (!scripts.isEmpty()) { startEval(); for (int i = 0; i < scripts.size(); i++) { getWrapped().write(scripts.get(i)); getWrapped().write(';'); } endEval(); } }
public void encodeJSONArray(String paramName, JSONArray jsonArray) throws IOException, JSONException { String json = jsonArray.toString(); json = EscapeUtils.forXml(json); getWrapped().write("\""); getWrapped().write(paramName); getWrapped().write("\":"); getWrapped().write(json); }
public void encodeCallbackParams(Map<String, Object> params) throws IOException, JSONException { if (params != null && !params.isEmpty()) { startExtension(CALLBACK_EXTENSION_PARAMS); getWrapped().write("{"); for (Iterator<String> it = params.keySet().iterator(); it.hasNext();) { String paramName = it.next(); Object paramValue = params.get(paramName); if (paramValue instanceof JSONObject) { encodeJSONObject(paramName, (JSONObject) paramValue); } else if (paramValue instanceof JSONArray) { encodeJSONArray(paramName, (JSONArray) paramValue); } else if (BeanUtils.isBean(paramValue)) { encodeJSONObject(paramName, new JSONObject(paramValue)); } else { encodeJSONValue(paramName, paramValue); } if (it.hasNext()) { getWrapped().write(","); } } getWrapped().write("}"); endExtension(); } }
@Override public void endDocument() throws IOException { FacesContext context = FacesContext.getCurrentInstance(); RequestContext requestContext = RequestContext.getCurrentInstance(context); if (requestContext != null) { try { if (context.isValidationFailed()) { requestContext.addCallbackParam("validationFailed", true); } encodeCallbackParams(requestContext.getCallbackParams()); encodeScripts(requestContext); } catch (Exception exception) { throw new AbortProcessingException(exception); } } wrapped.endDocument(); }
public void encodeJSONValue(String paramName, Object paramValue) throws IOException, JSONException { String json = new JSONObject().put(paramName, paramValue).toString(); json = EscapeUtils.forXml(json); getWrapped().write(json.substring(1, json.length() - 1)); }
@Override public PartialResponseWriter getPartialResponseWriter() { if (writer == null) { PartialResponseWriter parentWriter = getWrapped().getPartialResponseWriter(); writer = new PrimePartialResponseWriter(parentWriter); } return writer; }
public void encodeJSONObject(String paramName, JSONObject jsonObject) throws IOException, JSONException { String json = jsonObject.toString(); json = ComponentUtils.escapeXml(json); getWrapped().write("\""); getWrapped().write(paramName); getWrapped().write("\":"); getWrapped().write(json); }
public void encodeJSONArray(String paramName, JSONArray jsonArray) throws IOException, JSONException { String json = jsonArray.toString(); json = ComponentUtils.escapeXml(json); getWrapped().write("\""); getWrapped().write(paramName); getWrapped().write("\":"); getWrapped().write(json); }
public void encodeJSONValue(String paramName, Object paramValue) throws IOException, JSONException { String json = new JSONObject().put(paramName, paramValue).toString(); json = ComponentUtils.escapeXml(json); getWrapped().write(json.substring(1, json.length() - 1)); }