Package com.liferay.faces.bridge.container

Examples of com.liferay.faces.bridge.container.PortletContainer


  @Override
  public PortletContainer getPortletContainer(PortletRequest portletRequest, PortletResponse portletResponse,
    PortletContext portletContext, BridgeConfig bridgeConfig) {

    PortletContainer portletContainer = null;

    if (PortletContainerDetector.isPlutoPortletRequest(portletRequest)) {
      portletContainer = new PortletContainerPlutoTCKImpl(portletRequest, bridgeConfig);
    }
    else {
View Full Code Here


          else {

            // FACES-1496: Need to get the BridgeContext from the ThreadLocal in order to prevent memory
            // leaks with Mojarra.
            BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
            PortletContainer portletContainer = bridgeContext.getPortletContainer();
            long ifModifiedHeaderInMilliSeconds = portletContainer.getHttpServletRequestDateHeader(
                HEADER_IF_MODIFIED_SINCE);
            ifModifiedHeaderInSeconds = (long) (ifModifiedHeaderInMilliSeconds / 1000);

            if (logger.isDebugEnabled()) {
              logger.debug("resourceName=[{0}] portletContainer ifModifiedHeaderInSeconds=[{1}]",
View Full Code Here

    List<UIComponent> resourcesForAddingToHead = new ArrayList<UIComponent>();
    List<UIComponent> resourcesForRelocatingToBody = new ArrayList<UIComponent>();
    ExternalContext externalContext = facesContext.getExternalContext();
    PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
    PortletContainer portletContainer = bridgeContext.getPortletContainer();

    // Determine whether or not the portlet container is able to add script resources to the head.
    boolean portletContainerAbleToAddScriptResourceToHead = portletContainer.isAbleToAddScriptResourceToHead();

    // Determine whether or not this might be a Liferay runtime portlet (which does not have the ability to add
    // script resources to the head).
    Boolean renderPortletResource = (Boolean) portletRequest.getAttribute(BridgeConstants.RENDER_PORTLET_RESOURCE);
    boolean liferayRuntimePortlet = (renderPortletResource != null) && renderPortletResource.booleanValue();

    // Note: The HeadManagedBean is a ViewScoped manage-bean that keeps a list of resources that have been added to
    // the <head> section of the portal page. Note that the HeadManagedBean will be null in a JSP context since
    // there is no h:head JSP component tag in JSF 2.x.
    HeadManagedBean headManagedBean = HeadManagedBean.getInstance(facesContext);

    Set<String> headResourceIdsFromManagedBean = null;

    if (headManagedBean == null) {
      headResourceIdsFromManagedBean = new HashSet<String>();
    }
    else {
      headResourceIdsFromManagedBean = headManagedBean.getHeadResourceIds();
    }

    ComponentResourceFactory componentResourceFactory = (ComponentResourceFactory) FactoryExtensionFinder
      .getFactory(ComponentResourceFactory.class);

    // For each resource in the ViewRoot: Determine if it should added to the <head> section of the portal page,
    // or if it should be relocated to the body (which is actually not a <body> element, but a <div> element
    // rendered by the bridge's BodyRenderer).
    for (UIComponent uiComponentResource : uiComponentResources) {

      // If this is taking place during an Ajax request or this is a Liferay runtime portlet, then
      if (ajaxRequest || liferayRuntimePortlet) {

        // Determine whether or not the resource is already present in the <head> section of the portal page.
        // Note that this can happen in one of two ways: 1) If this is NON-Liferay-Runtime portlet (currently
        // doing Ajax) but has already added the resource during initial page HTTP-GET render, or 2) By another
        // NON-Liferay-Runtime portlet that has already added the same JavaScript resource.
        ComponentResource componentResource = componentResourceFactory.getComponentResource(
            uiComponentResource);
        boolean alreadyPresentInPortalPageHead = headResourceIdsFromManagedBean.contains(
            componentResource.getId());

        // If the resource is already present in the <head> section of the portal page, then simply output a
        // logger message to this fact.
        if (alreadyPresentInPortalPageHead) {

          if (logger.isDebugEnabled()) {

            logger.debug(
              "Resource already present in head: name=[{0}] library=[{1}] rendererType=[{2}] value=[{3}] className=[{4}]",
              new Object[] {
                componentResource.getName(), componentResource.getLibrary(),
                uiComponentResource.getRendererType(),
                ComponentResourceUtil.getComponentValue(uiComponentResource),
                uiComponentResource.getClass().getName(),
              });
          }
        }

        // Otherwise, since it is not possible to add it to the <head> section, the resource must be relocated
        // to the body.
        else {
          logger.debug(
            "Relocating resource to body (since it was added via Ajax and is not yet present in head): name=[{0}] library=[{1}] rendererType=[{2}] value=[{3}] className=[{4}]",
            new Object[] {
              componentResource.getName(), componentResource.getLibrary(),
              uiComponentResource.getRendererType(),
              ComponentResourceUtil.getComponentValue(uiComponentResource),
              uiComponentResource.getClass().getName(),
            });

          resourcesForRelocatingToBody.add(uiComponentResource);
        }
      }

      // Otherwise, if the portlet container has the ability to add resources to the <head> section of the
      // portal page, then add it to the list of resources that are to be added to the <head> section.
      else if (portletContainerAbleToAddScriptResourceToHead) {
        resourcesForAddingToHead.add(uiComponentResource);
      }

      // Otherwise, we have no choice but to add it to the list of resources that are to be relocated to
      // the body.
      else {
        resourcesForRelocatingToBody.add(uiComponentResource);
      }
    }

    // If the portlet container has the ability to add resources to the <head> section of the portal page, then
    if (portletContainerAbleToAddScriptResourceToHead) {

      // Save a temporary reference to the ResponseWriter provided by the FacesContext.
      ResponseWriter responseWriterBackup = facesContext.getResponseWriter();

      // Replace the ResponseWriter in the FacesContext with a HeadResponseWriter that knows how to write to
      // the <head>...</head> section of the rendered portal page.
      HeadResponseWriter headResponseWriter = (HeadResponseWriter) portletRequest.getAttribute(
          HeadResponseWriter.class.getName());

      if (headResponseWriter == null) {
        headResponseWriter = (HeadResponseWriter) portletContainer.getHeadResponseWriter(responseWriterBackup);
      }

      portletRequest.setAttribute(HeadResponseWriter.class.getName(), headResponseWriter);
      facesContext.setResponseWriter(headResponseWriter);
View Full Code Here

  @Override
  protected boolean isAbleToSetHttpStatusCode(FacesContext facesContext) {

    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
    PortletContainer portletContainer = bridgeContext.getPortletContainer();

    return portletContainer.isAbleToSetHttpStatusCode();
  }
View Full Code Here

    portletRequest.setAttribute(Bridge.PORTLET_LIFECYCLE_PHASE, portletPhase);

    // Initialize the portlet container implementation.
    PortletContainerFactory portletContainerFactory = (PortletContainerFactory) FactoryExtensionFinder.getFactory(
        PortletContainerFactory.class);
    PortletContainer portletContainer = portletContainerFactory.getPortletContainer(portletRequest, portletResponse,
        portletContext, bridgeConfig);

    // Initialize the bridge request scope.
    initBridgeRequestScope(portletRequest, portletResponse, portletPhase, portletContainer, incongruityContext);
View Full Code Here

  // serialVersionUID
  private static final long serialVersionUID = 3383713726298508807L;

  public void afterPhase(PhaseEvent phaseEvent) {
    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
    PortletContainer portletContainer = bridgeContext.getPortletContainer();
    PhaseId phaseId = portletContainer.getPhaseId();

    if ((phaseId != null) && ((phaseId == PhaseId.ANY_PHASE) || (phaseId == phaseEvent.getPhaseId()))) {
      portletContainer.afterPhase(phaseEvent);
    }
  }
View Full Code Here

    }
  }

  public void beforePhase(PhaseEvent phaseEvent) {
    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
    PortletContainer portletContainer = bridgeContext.getPortletContainer();
    PhaseId phaseId = portletContainer.getPhaseId();

    if ((phaseId != null) && ((phaseId == PhaseId.ANY_PHASE) || (phaseId == phaseEvent.getPhaseId()))) {
      portletContainer.beforePhase(phaseEvent);
    }
  }
View Full Code Here

  protected boolean namespacedParameters;

  public ResponseWriterBridgeCompat_2_0_Impl(ResponseWriter wrappedResponseWriter) {

    BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
    PortletContainer portletContainer = bridgeContext.getPortletContainer();
    boolean portletContainerNamespacesParameters = portletContainer.isNamespacedParameters();
    this.namespacedParameters = portletContainerNamespacesParameters && JSF_RUNTIME_SUPPORTS_NAMESPACING_VIEWSTATE;
  }
View Full Code Here

    FacesRequestParameterMap facesRequestParameterMap = null;
    PortletRequest portletRequest = bridgeContext.getPortletRequest();
    PortletResponse portletResponse = bridgeContext.getPortletResponse();
    String namespace = portletResponse.getNamespace();
    PortletContainer portletContainer = bridgeContext.getPortletContainer();
    BridgeRequestScope bridgeRequestScope = bridgeContext.getBridgeRequestScope();
    String defaultRenderKitId = bridgeContext.getDefaultRenderKitId();
    Map<String, String> facesViewParameterMap = getFacesViewParameterMap(bridgeContext);

    if (portletRequest instanceof ClientDataRequest) {
View Full Code Here

          put(HEADER_FACES_REQUEST, new String[] { PARTIAL_AJAX });
        }
      }
    }

    PortletContainer portletContainer = bridgeContext.getPortletContainer();

    if (!foundUserAgent) {
      put(HEADER_USER_AGENT, portletContainer.getHeader(HEADER_USER_AGENT));
    }

    addJSF1Headers(portletContainer);
  }
View Full Code Here

TOP

Related Classes of com.liferay.faces.bridge.container.PortletContainer

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.