Пример #1
0
  public static void renderScript(
      FacesContext facesContext, UIComponent uiComponent, String script, String use) {

    // Render the script at the bottom of the page by setting the WebKeys.AUI_SCRIPT_DATA request
    // attribute.
    ExternalContext externalContext = facesContext.getExternalContext();
    ClientScriptFactory clientScriptFactory =
        (ClientScriptFactory) FactoryExtensionFinder.getFactory(ClientScriptFactory.class);
    ClientScript clientScript = clientScriptFactory.getClientScript(externalContext);

    String portletId = StringPool.BLANK;
    Object portlet = externalContext.getRequestMap().get(WebKeys.RENDER_PORTLET);

    if (portlet != null) {
      portletId = LiferayPortletUtil.getPortletId(portlet);
    }

    clientScript.append(portletId, script, use);
  }