Package com.liferay.faces.bridge.context.url

Examples of com.liferay.faces.bridge.context.url.BridgeResourceURL


    if (uiViewRoot != null) {
      currentFacesViewId = uiViewRoot.getViewId();
    }

    BridgeResourceURL bridgeResourceURL = bridgeURLFactory.getBridgeResourceURL(url, currentFacesViewId, this);

    // If the "javax.portlet.faces.ViewLink" parameter is found and set to "true", then
    String viewLinkParam = bridgeResourceURL.getParameter(Bridge.VIEW_LINK);

    if (BooleanHelper.isTrueToken(viewLinkParam)) {

      // Since this is going to be a URL that represents navigation to a different viewId,
      // need to remove the "javax.portlet.faces.ViewLink" parameter as required by the Bridge
      // Spec.
      bridgeResourceURL.removeParameter(Bridge.VIEW_LINK);

      // Set a flag indicating that this is a view-link type of navigation.
      bridgeResourceURL.setViewLink(true);

      // If the "javax.portlet.faces.BackLink" parameter is found, then replace it's value
      // with a URL that can cause navigation back to the current view.
      if (bridgeResourceURL.getParameter(Bridge.BACK_LINK) != null) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        bridgeResourceURL.replaceBackLinkParameter(facesContext);
      }
    }

    // If the specified URL is opaque, meaning it starts with something like "portlet:" or "mailto:" and
    // doesn't have the double-forward-slash like "http://" does, then
    if (bridgeResourceURL.isOpaque()) {

      // If the specified URL starts with "portlet:", then
      if (bridgeResourceURL.isPortletScheme()) {

        // If the "_jsfBridgeViewId" URL parameter is equal to "_jsfBridgeCurrentView" then the
        // URL is self-referencing and the "_jsfBridgeViewId" parameter muse be removed from the
        // URL.
        String facesViewIdParameter = bridgeResourceURL.getParameter(Bridge.FACES_VIEW_ID_PARAMETER);

        if (Bridge.FACES_USE_CURRENT_VIEW_PARAMETER.equals(facesViewIdParameter)) {
          bridgeResourceURL.setSelfReferencing(true);
          bridgeResourceURL.removeParameter(Bridge.FACES_VIEW_ID_PARAMETER);
        }

        // If the "_jsfBridgeViewPath" URL parameter is equal to "_jsfBridgeCurrentView" then
        // the URL is self-referencing and the "_jsfBridgeViewPath" parameter muse be removed
        // from the URL.
        String facesViewPathParameter = bridgeResourceURL.getParameter(Bridge.FACES_VIEW_PATH_PARAMETER);

        if (Bridge.FACES_USE_CURRENT_VIEW_PARAMETER.equals(facesViewPathParameter)) {
          bridgeResourceURL.setSelfReferencing(true);
          bridgeResourceURL.removeParameter(Bridge.FACES_VIEW_PATH_PARAMETER);
        }
      }
    }

    // Otherwise, if the specified URL is hierarchical and targets an external resource, then
    else if (bridgeResourceURL.isHierarchical() && bridgeResourceURL.isExternal()) {

      // If the "javax.portlet.faces.BackLink" parameter is found, then replace it's value with
      // a URL that can cause navigation back to the current view.
      if (bridgeResourceURL.getParameter(Bridge.BACK_LINK) != null) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        bridgeResourceURL.replaceBackLinkParameter(facesContext);
      }
    }

    // Otherwise, if the specified URL is hierarchical and targets a resource internal to this
    // application, then
    else if (bridgeResourceURL.isHierarchical() && !bridgeResourceURL.isExternal()) {

      // If the "javax.portlet.faces.BackLink" parameter is found, then replace it's value with a URL
      // that can cause navigation back to the current view.
      if (bridgeResourceURL.getParameter(Bridge.BACK_LINK) != null) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        bridgeResourceURL.replaceBackLinkParameter(facesContext);
      }

      // If the "javax.portlet.faces.InProtocolResourceLink" parameter is found, then
      if ((bridgeResourceURL.getParameter(Bridge.IN_PROTOCOL_RESOURCE_LINK) != null)) {
        bridgeResourceURL.setInProtocol(true);

        // Since an in-protocol-resource URL must be a ResourceURL, the
        // "javax.portlet.faces.PortletMode" and "javax.portlet.faces.WindowState" parameters must
        // be removed from the URL (if present) because you can change a PortletMode or WindowState
        // in a ResourceRequest.
        bridgeResourceURL.removeParameter(Bridge.PORTLET_MODE_PARAMETER);
        bridgeResourceURL.removeParameter(Bridge.PORTLET_WINDOWSTATE_PARAMETER);

        // The Bridge Spec indicates that the "javax.portlet.faces.Secure" parameter must be
        // removed but must also be used to set the security of the ResourceURL below.
        String secureParam = bridgeResourceURL.getParameter(Bridge.PORTLET_SECURE_PARAMETER);
        bridgeResourceURL.setSecure(BooleanHelper.isTrueToken(secureParam));
        bridgeResourceURL.removeParameter(Bridge.PORTLET_SECURE_PARAMETER);
      }
    }

    return bridgeResourceURL;
  }
View Full Code Here

TOP

Related Classes of com.liferay.faces.bridge.context.url.BridgeResourceURL

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.