protected void encodeButton(FacesContext context, UIComponent component) throws IOException {
    FacesContext currentInstance = FacesContext.getCurrentInstance();
    ScrollButton scrollButton = (ScrollButton) component;
    ResponseWriter writer = context.getResponseWriter();

    writeIdAttribute(context, scrollButton);
    writer.startElement("div", scrollButton);
    writer.writeAttribute(
        "class",
        Styles.getCSSClass(
            context,
            scrollButton,
            scrollButton.getButtonStyle(),
            StyleGroup.regularStyleGroup(),
            scrollButton.getButtonClass(),
            getDefaultScrollButtonClass()),
        null);
    writer.writeAttribute("nowrap", "nowrap", null);
    writer.writeAttribute("align", "center", null);
    writer.writeAttribute("valign", "middle", null);

    String imageUrl;
    String buttonImageUrl = (String) scrollButton.getAttributes().get("buttonImageUrl");
    if (scrollButton.getScrollDirection().equals(ScrollDirection.UP))
      imageUrl = Resources.getURL(context, buttonImageUrl, null, "input/scrollButtonUp.gif");
    else imageUrl = Resources.getURL(context, buttonImageUrl, null, "input/scrollButtonDown.gif");
    writer.startElement("img", scrollButton);
    writeIdAttribute(context, scrollButton);
    writer.writeAttribute("src", imageUrl, null);
    writer.endElement("img");

    writer.endElement("div");
    InitScript initScript = renderInitScript(currentInstance, scrollButton);
    Rendering.renderInitScripts(currentInstance, initScript);
  }
Example #2
0
  private void renderScripts(FacesContext context, UIComponent component) throws IOException {
    final ChartPopup popup = (ChartPopup) component;
    final String clientId = popup.getClientId(context);
    final boolean clientLoadingMode = popup.getLoadingMode().equals(LoadingMode.CLIENT);

    final UIComponent chartView = popup.getParent();
    final Chart chart = (Chart) chartView.getParent();
    final Integer entityIndex = chart.getEntityIndex();
    chart.setEntityIndex(-1);
    final String chartId = chart.getClientId(context);
    chart.setEntityIndex(entityIndex);

    ScriptBuilder buf = new ScriptBuilder();
    buf.functionCall("O$.ChartPopup._init", clientId, popup.getLoadingMode().toString(), chartId)
        .semicolon();

    Rendering.renderInitScript(
        context,
        buf,
        Resources.utilJsURL(context),
        Resources.internalURL(context, "chart/chart.js"),
        (!clientLoadingMode ? Resources.ajaxUtilJsURL(context) : null));
  }
  protected InitScript renderInitScript(FacesContext context, ScrollButton scrollButton)
      throws IOException {
    ScriptBuilder buf = new ScriptBuilder();
    JSONObject stylingParams = getStylingParamsObj(context, scrollButton);

    buf.initScript(
        context,
        scrollButton,
        "O$.ScrollButton._init",
        scrollButton.getParent().getClientId(context),
        scrollButton.getScrollDirection().toString(),
        stylingParams);
    return new InitScript(
        buf.toString(),
        new String[] {
          TableUtil.getTableUtilJsURL(context),
          Resources.internalURL(context, "timetable/scrollButton.js")
        });
  }
Example #4
0
  @Override
  public void renderView(FacesContext context, UIViewRoot root) throws IOException, FacesException {
    Components.runScheduledActions();
    if (!context.getResponseComplete()) {

      ExternalContext externalContext = context.getExternalContext();
      Object session = externalContext.getSession(false);
      Map<String, Object> requestMap = externalContext.getRequestMap();

      if (externalContext.getSessionMap().containsKey(ERROR_OCCURRED_UNDER_PORTLETS)) {
        processExceptionUnderPortlets(context);
        return;
      }

      if (AjaxUtil.isPortletRequest(context)
          && Environment.isMyFaces()
          && isNewSession(externalContext.getSession(false))) {
        processSessionExpirationUnderPortletsMyFaces(context, root, externalContext, session);
      }

      if (AjaxUtil.isPortletRequest(context)
          && Environment.isRI()
          && isNewSession(externalContext.getSession(false))) {
        processSessionExpirationUnderPortletsRI(context, root, externalContext);
      }

      boolean ajaxRequest = AjaxUtil.isAjaxRequest(context);
      if (!ajaxRequest && !AjaxUtil.isAjax4jsfRequest())
        ValidationSupportResponseWriter.resetBubbleIndex(context);

      if (ajaxRequest) {
        updateSessionExpirationFlagUnderPortlets(context, root, externalContext, requestMap);
        try {
          // HACK for MyFaces ( <f:view> tag not call renderers )
          // ServletResponse response = (ServletResponse) context
          //		.getExternalContext().getResponse();
          Object response = externalContext.getResponse();

          if (!AjaxUtil.isPortletRequest(context)) {
            try {
              response.getClass().getDeclaredMethod("resetResponse").invoke(response);
              // response.reset();
            } catch (Exception e) {
              // Do nothing - we will use directly and reset
              // wrapper
            }
          }

          if (requestMap.containsKey(SESSION_EXPIRATION_PROCESSING)) {
            super.renderView(context, root);
            // This is done for MyFaces use-case, because MyFaces doesn't call rendering methods for
            // ViewRoot
            if (!Environment.isRI()) {
              root.encodeChildren(context);
            }
            Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
            if (sessionMap != null && !sessionMap.containsKey(SESSION_SCOPED_PARAMETER)) {
              sessionMap.put(SESSION_SCOPED_PARAMETER, Boolean.TRUE.toString());
            }
            return;
          }

          if (Environment.isFacelets(context)) {
            super.renderView(context, root);
          } else {
            root.encodeBegin(context);
            if (root.getRendersChildren()) {
              root.encodeChildren(context);
            }
            root.encodeEnd(context);
          }
        } catch (RuntimeException e) {
          CommonAjaxViewRoot.processExceptionDuringAjax(context, e);
          externalContext.log(e.getMessage(), e);
        } catch (Error e) {
          CommonAjaxViewRoot.processExceptionDuringAjax(context, e);
          externalContext.log(e.getMessage(), e);
        }

      } else {

        super.renderView(context, root);
        Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
        if (sessionMap != null && !sessionMap.containsKey(SESSION_SCOPED_PARAMETER)) {
          sessionMap.put(SESSION_SCOPED_PARAMETER, Boolean.TRUE.toString());
        }

        if (AjaxUtil.isAjax4jsfRequest()) {
          Resources.processHeadResources(context);
        }
      }
    }
  }