Package com.liferay.faces.util.render

Examples of com.liferay.faces.util.render.BufferedScriptResponseWriter


    // Otherwise,
    else {

      // Ask the children to encode themselves and capture the markup in a string.
      ResponseWriter backupResponseWriter = facesContext.getResponseWriter();
      BufferedScriptResponseWriter bufferedScriptResponseWriter = new BufferedScriptResponseWriter();
      facesContext.setResponseWriter(bufferedScriptResponseWriter);
      super.encodeChildren(facesContext, uiComponent);
      facesContext.setResponseWriter(backupResponseWriter);

      // If running in an Ajax request, then it is not possible to render the scripts at the bottom of the
      // portal page. Instead, store the script in the JavaScript map so that PartialViewContextCleanupImpl
      // knows to include it in the <eval>...</eval> section of the JSF partial-response.
      if (isAjaxRequest(facesContext)) {
        Map<String, String> javaScriptMap = ExtFacesContext.getInstance().getJavaScriptMap();
        javaScriptMap.put(uiComponent.getClientId(facesContext), bufferedScriptResponseWriter.toString());
      }

      // Otherwise, render the script at the bottom of the portal page by setting the WebKeys.AUI_SCRIPT_DATA
      // request attribute.
      else {
        Map<String, Object> attributes = uiComponent.getAttributes();
        String use = (String) attributes.get(USE);
        String bufferedScript = bufferedScriptResponseWriter.toString();
        RendererUtil.renderScript(facesContext, uiComponent, bufferedScript, use);
      }
    }
  }
View Full Code Here


      String target = outputScript.getTarget();

      if (StringPool.BODY.equals(target) && !facesContext.getPartialViewContext().isAjaxRequest()) {

        ResponseWriter responseWriter = facesContext.getResponseWriter();
        BufferedScriptResponseWriter bufferedScriptResponseWriter = new BufferedScriptResponseWriter();
        facesContext.setResponseWriter(bufferedScriptResponseWriter);

        // Note: If the script uses YUI or AlloyUI modules then a YUI sandbox will be created automatically by
        // the ClientScript when RendererUtil.renderScript() is called below.
        if ((use != null) && (use.length() > 0)) {
          super.encodeChildren(facesContext, uiComponent);
        }

        // Otherwise the sandbox the script with an anonymous self-executing function.
        else {
          bufferedScriptResponseWriter.write(FUNCTION_BEGIN_SCRIPT);
          super.encodeChildren(facesContext, uiComponent);
          bufferedScriptResponseWriter.write(FUNCTION_END_SCRIPT);
        }

        // Render the script at the bottom of the page immediately before the closing </body> tag.
        String bufferedScript = bufferedScriptResponseWriter.toString();
        RendererUtil.renderScript(facesContext, uiComponent, bufferedScript, use);
        facesContext.setResponseWriter(responseWriter);
      }

      // Otherwise if the script uses YUI or AlloyUI modules then create a YUI sandbox which specifies the
View Full Code Here

        }

        resultArrayStringBuilder.append(StringPool.CLOSE_BRACKET);

        // Buffer all JavaScript so that it is rendered in the <eval> section of the partial response.
        BufferedScriptResponseWriter bufferedScriptResponseWriter = new BufferedScriptResponseWriter();

        //J-
        // LFAI.recieveAutoCompleteResults(Liferay.component('clientKey'), ['item1', 'item2', 'item3'],
        //    'hiddenClientId')
        //J+
        RendererUtil.encodeFunctionCall(bufferedScriptResponseWriter, "LFAI.setAutoCompleteServerResults",
          liferayComponentJavaScriptFragment, resultArrayStringBuilder, hiddenClientId);

        String bufferedScriptString = bufferedScriptResponseWriter.toString();
        Map<String, String> javaScriptMap = ExtFacesContext.getInstance().getJavaScriptMap();
        javaScriptMap.put(clientId, bufferedScriptString);
      }
      else {
        super.encodeJavaScript(facesContext, uiComponent);
View Full Code Here

TOP

Related Classes of com.liferay.faces.util.render.BufferedScriptResponseWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.