Package com.liferay.faces.bridge.context

Examples of com.liferay.faces.bridge.context.BridgeContext


    // no-op
    return null;
  }

  public String getRequestParameter(String name) {
    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();

    return fixRequestParameterValue(bridgeContext.getPortletRequest().getParameter(name));
  }
View Full Code Here


    return fixRequestParameterValue(bridgeContext.getPortletRequest().getParameter(name));
  }

  public String[] getRequestParameterValues(String name) {
    String[] values = null;
    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
    String[] originalValues = bridgeContext.getPortletRequest().getParameterValues(name);

    if (originalValues != null) {
      values = new String[originalValues.length];

      for (int i = 0; i < originalValues.length; i++) {
View Full Code Here

  }

  public String getRequestQueryString() {

    if (requestQueryString == null) {
      BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
      PortletRequest portletRequest = bridgeContext.getPortletRequest();
      requestQueryString = (String) portletRequest.getAttribute(REQUEST_ATTR_QUERY_STRING);

      if (requestQueryString == null) {

        // Some portlet bridges wrap the portal's PortletRequest implementation instance (which prevents us from
View Full Code Here

    if (requestURL == null) {

      // Note that this is an approximation (best guess) of the original URL.
      StringBuilder buf = new StringBuilder();
      BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
      PortletRequest portletRequest = bridgeContext.getPortletRequest();
      buf.append(portletRequest.getScheme());
      buf.append(StringPool.COLON);
      buf.append(StringPool.FORWARD_SLASH);
      buf.append(StringPool.FORWARD_SLASH);
      buf.append(portletRequest.getServerName());
View Full Code Here

  public String getResponseNamespace() {

    if (responseNamespace == null) {

      BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
      responseNamespace = bridgeContext.getPortletResponse().getNamespace();

      if (BridgeConstants.WSRP_REWRITE.equals(responseNamespace)) {
        responseNamespace = bridgeContext.getPortletConfig().getPortletName() +
          bridgeContext.getPortletContext().getPortletContextName();
      }
    }

    return responseNamespace;
  }
View Full Code Here

  @Override
  public PortletURL createRedirectURL(String fromURL, Map<String, List<String>> parameters)
    throws MalformedURLException {

    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
    LiferayPortletResponse liferayPortletResponse = new LiferayPortletResponse(bridgeContext.getPortletResponse());

    PortletURL redirectURL = liferayPortletResponse.createRenderURL();

    copyRequestParameters(fromURL, redirectURL);
View Full Code Here

  }

  @Override
  public void redirect(String url) throws IOException {

    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();

    PortletResponse portletResponse = bridgeContext.getPortletResponse();

    if (portletResponse instanceof ActionResponse) {
      LiferayPortletResponse liferayActionResponse = new LiferayPortletResponse(portletResponse);
      liferayActionResponse.sendRedirect(url);
    }
View Full Code Here

    boolean restoreNonExcludedRequestAttributes = ((beganInPhase == Bridge.PortletPhase.ACTION_PHASE) ||
        (beganInPhase == Bridge.PortletPhase.EVENT_PHASE) ||
        (beganInPhase == Bridge.PortletPhase.RESOURCE_PHASE));

    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();

    PortletPhase portletRequestPhase = bridgeContext.getPortletRequestPhase();

    if (portletRequestPhase == Bridge.PortletPhase.RENDER_PHASE) {

      if (!portletMode.equals(bridgeContext.getPortletRequest().getPortletMode())) {
        setPortletModeChanged(true);
        restoreNonExcludedRequestAttributes = false;
      }
    }

    if ((beganInPhase == Bridge.PortletPhase.ACTION_PHASE) || (beganInPhase == Bridge.PortletPhase.EVENT_PHASE) ||
        (beganInPhase == Bridge.PortletPhase.RESOURCE_PHASE)) {

      // Restore the view root that may have been saved during the action/event/render phase of the portlet
      // lifecycle.
      UIViewRoot uiViewRoot = (UIViewRoot) getAttribute(BRIDGE_REQ_SCOPE_ATTR_FACES_VIEW_ROOT);

      if (uiViewRoot != null) {
        facesContext.setViewRoot(uiViewRoot);
        logger.debug("Restored viewId=[{0}] uiViewRoot=[{1}]", uiViewRoot.getViewId(), uiViewRoot);
      }
      else {
        logger.debug("Did not restore uiViewRoot");
      }

      // Restore the faces messages that may have been saved during the action/event/render phase of the portlet
      // lifecycle.
      List<FacesMessageWrapper> facesMessages = (List<FacesMessageWrapper>) getAttribute(
          BRIDGE_REQ_SCOPE_ATTR_FACES_MESSAGES);

      boolean restoredFacesMessages = false;

      if (facesMessages != null) {

        for (FacesMessageWrapper facesMessageWrapper : facesMessages) {
          String clientId = facesMessageWrapper.getClientId();
          FacesMessage facesMessage = facesMessageWrapper.getFacesMessage();
          facesContext.addMessage(clientId, facesMessage);
          logger.trace("Restored facesMessage=[{0}]", facesMessage.getSummary());
          restoredFacesMessages = true;
        }
      }

      if (restoredFacesMessages) {
        logger.debug("Restored facesMessages");
      }
      else {
        logger.debug("Did not restore any facesMessages");
      }

      // NOTE: PROPOSE-FOR-BRIDGE3-API: https://issues.apache.org/jira/browse/PORTLETBRIDGE-203 Restore the
      // FacesContext attributes that may have been saved during the ACTION_PHASE of the portlet lifecycle.
      restoreJSF2FacesContextAttributes(facesContext);
    }

    if (restoreNonExcludedRequestAttributes) {

      // Restore the non-excluded request attributes.
      List<RequestAttribute> savedRequestAttributes = (List<RequestAttribute>) getAttribute(
          BRIDGE_REQ_SCOPE_ATTR_REQUEST_ATTRIBUTES);

      boolean restoredNonExcludedRequestAttributes = false;

      if (savedRequestAttributes != null) {
        ExternalContext externalContext = facesContext.getExternalContext();
        Map<String, Object> currentRequestAttributes = externalContext.getRequestMap();

        // If a redirect did not occur, then restore the non-excluded request attributes.
        if (!isRedirectOccurred()) {

          for (RequestAttribute requestAttribute : savedRequestAttributes) {
            String name = requestAttribute.getName();
            Object value = requestAttribute.getValue();
            logger.trace("Restoring non-excluded request attribute name=[{0}] value=[{1}]", name, value);
            currentRequestAttributes.put(name, value);
            restoredNonExcludedRequestAttributes = true;
          }
        }
      }

      if (restoredNonExcludedRequestAttributes) {
        logger.debug("Restored non-excluded request attributes");
      }
      else {
        logger.debug("Did not restore any non-excluded request attributes");
      }
    }

    // If running in the RENDER_PHASE, then the Flash scope must be restored.
    if (portletRequestPhase == Bridge.PortletPhase.RENDER_PHASE) {

      // NOTE: PROPOSED-FOR-BRIDGE3-API: https://issues.apache.org/jira/browse/PORTLETBRIDGE-201
      // Restore the flash scope.
      ExternalContext externalContext = facesContext.getExternalContext();
      restoreFlashState(externalContext);

      // PROPOSE-FOR-BRIDGE3-API
      restoreClientWindow(facesContext.getExternalContext());
    }

    // If running in the RENDER_PHASE, then the incongruity context must be restored.
    if (((beganInPhase == Bridge.PortletPhase.ACTION_PHASE) || (beganInPhase == Bridge.PortletPhase.EVENT_PHASE)) &&
        (portletRequestPhase == Bridge.PortletPhase.RENDER_PHASE)) {

      List<IncongruityAttribute> savedIncongruityAttributes = (List<IncongruityAttribute>) getAttribute(
          BRIDGE_REQ_SCOPE_ATTR_INCONGRUITY_CONTEXT_ATTRIBUTES);

      if (savedIncongruityAttributes != null) {

        IncongruityContext incongruityContext = bridgeContext.getIncongruityContext();
        Map<String, Object> incongruityContextAttributes = incongruityContext.getAttributes();

        for (IncongruityAttribute incongruityAttribute : savedIncongruityAttributes) {
          String key = incongruityAttribute.getName();
          Object value = incongruityAttribute.getValue();
View Full Code Here

  }

  @Override
  protected PortletURL createActionURL(MimeResponse mimeResponse) {

    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();

    return liferayURLFactory.getLiferayActionURL(bridgeContext, mimeResponse, portletResponseNamespace,
        friendlyURLMapperEnabled);
  }
View Full Code Here

  }

  @Override
  protected PortletURL createRenderURL(MimeResponse mimeResponse) {

    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();

    return liferayURLFactory.getLiferayRenderURL(bridgeContext, mimeResponse, portletResponseNamespace,
        friendlyURLMapperEnabled);
  }
View Full Code Here

TOP

Related Classes of com.liferay.faces.bridge.context.BridgeContext

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.