Package org.jboss.portletbridge.application

Examples of org.jboss.portletbridge.application.PortletWindowState


      setupActionRequest();
      request.setAttribute(Bridge.PORTLET_LIFECYCLE_PHASE, Bridge.PortletPhase.ActionPhase);
      request.setAttribute(AbstractExternalContext.PORTLET_CONFIG_ATTRIBUTE,
            portletConfig);
      PortletStateHolder portletStateHolder = PortletStateHolder.init(new MockPortletContext(servletContext));
      PortletWindowState portletState = new PortletWindowState(){

     @Override
     public BridgeConfig getBridgeConfig() {
       return new BridgeConfig(){

         public Map<String, String> getDefaultViewIdMap() {
        HashMap<String, String> viewIdMap = new HashMap<String,String>();
        viewIdMap.put("view", "/foo.xhtml");
        return viewIdMap;
         }

         public Set<ExcludedRequestAttribute> getExcludedAttributes() {
           // TODO Auto-generated method stub
           return null;
         }

         public List<String> getFacesServletMappings() {
           // TODO Auto-generated method stub
           return null;
         }

         public String getInitParameter(String name) {
           // TODO Auto-generated method stub
           return null;
         }

         public PortletConfig getPortletConfig() {
           // TODO Auto-generated method stub
           return null;
         }

         public String getPortletName() {
           // TODO Auto-generated method stub
           return null;
         }

         public boolean isPreserveActionParams() {
           // TODO Auto-generated method stub
           return false;
         }

      public Map<Class<? extends Throwable>, String> getErrorPages() {
        // TODO Auto-generated method stub
        return null;
      }

            public Lifecycle getFacesLifecycle() {
               return null;
            }

         };
     }
       
      };
      portletStateHolder.addWindowState(STATE_ID, portletState);
      PortletBridgeContext bridgeContext = portletState.createBridgeContext();
      actionRequest.setAttribute(PortletBridgeContext.REQUEST_PARAMETER_NAME, bridgeContext);

      return new PortletExternalContextImpl(portletContext,actionRequest,actionResponse);
   }
View Full Code Here


          + getPortletName());
    }
    initRequest(request, response, Bridge.PortletPhase.ActionPhase);
    StateId stateId = getStateHolder()
        .getStateId(getPortletName(), request);
    PortletWindowState windowState = new PortletWindowState() {

      @Override
      public BridgeConfig getBridgeConfig() {
        return AjaxPortletBridge.this;
      }

    };
    PortletBridgeContext bridgeContext = createBridgeContext(request,
        windowState);
    bridgeContext.setStateId(stateId);
    FacesContext facesContext = getFacesContext(request, response);
    try {
      execute(facesContext);
      // save request scope variables and Faces Messages.
      if (!facesContext.getResponseComplete()) {
        // Setup portlet modes from parameters.
        Map<String, String[]> viewIdParameters = (Map<String, String[]>) facesContext
            .getExternalContext().getRequestMap().get(
                VIEW_ID_PARAMETERS);
        if (null != viewIdParameters && viewIdParameters.size() > 0) {
          processPortletParameters(response, stateId, facesContext,
              facesContext.getViewRoot().getViewId(),
              viewIdParameters);
        }
        // Save view state for a render phases.
        facesContext.getApplication().getStateManager().saveView(
            facesContext);
        windowState.saveRequest(facesContext);
      } else {
        windowState.reset();
        windowState.saveSeamConversationId(facesContext);
        String redirectViewId = bridgeContext.getRedirectViewId();
        if (null != redirectViewId) {
          windowState.setViewId(redirectViewId);
          // Save redirect request parameters.
          Map<String, String[]> newRequestParameters = bridgeContext
              .getRedirectRequestParameters();
          windowState.setRequestParameters(newRequestParameters);
          processPortletParameters(response, stateId, facesContext,
              redirectViewId, newRequestParameters);
        }
      }
      // TODO - detect portlet mode changes ( by the viewId parameter. )
View Full Code Here

    initRequest(request, wrappedResponse, Bridge.PortletPhase.RenderPhase);
    String namespace = wrappedResponse.getNamespace();
    StateId stateId = getStateHolder().getStateId(getPortletName(),
        request, namespace);

    PortletWindowState windowState = getStateHolder().getWindowState(
        stateId);
    if (null == windowState) {
      windowState = new PortletWindowState() {

        @Override
        public BridgeConfig getBridgeConfig() {
          return AjaxPortletBridge.this;
        }

      };
      getStateHolder().addWindowState(stateId, windowState);
    }
    PortletBridgeContext bridgeContext = createBridgeContext(request,
        windowState);
    bridgeContext.setStateId(stateId);

    FacesContext facesContext = getFacesContext(request, wrappedResponse);


    try {
      windowState.restoreRequest(facesContext, true);
      // If we're using RichFaces, setup proper parameters for this render
      // request
      if (RICHFACES_ENABLED) {
        setupAjaxParams(facesContext, stateId.toString(), namespace);
      }
      // set portletbridge title if its set.
      ResourceBundle bundle = portletConfig.getResourceBundle(request
          .getLocale());
      if (bundle != null) {
        String title = null;
        try {
          title = bundle.getString("javax.portlet.title");
          wrappedResponse.setTitle(title);
        } catch (Exception e) {
          // Ignore MissingResourceException
        }
      }

      try {

        renderResponse(facesContext, windowState);
        // TODO - detect redirect case. Reset response, clear request
        // variables as far as Seam state.
        // Perform new render phase with a new ViewId.
        String redirectViewId = bridgeContext.getRedirectViewId();
        if (null != redirectViewId) {
          windowState.reset();
          windowState.setViewId(redirectViewId);

          Map<String, String[]> redirectParams = bridgeContext
              .getRedirectRequestParameters();

          // release old FacesContext.
          facesContext.release();
          // Reset attributes to initial state
          Set<String> initialAttributes = bridgeContext
              .getInitialRequestAttributeNames();
          List<String> currentAttributes = Collections.list(request
              .getAttributeNames());
          currentAttributes.removeAll(initialAttributes);
          for (Object newAttribute : currentAttributes) {
            request.removeAttribute((String) newAttribute);
          }
          if (redirectParams != null) {
            windowState.setRequestParameters(redirectParams);
          }

          // Create new FacesContext
          facesContext = getFacesContext(request, wrappedResponse);
          ViewHandler viewHandler = facesContext.getApplication()
              .getViewHandler();
          UIViewRoot viewRoot = viewHandler.createView(facesContext,
              redirectViewId);
          facesContext.setViewRoot(viewRoot);
          renderResponse(facesContext, windowState);
        }
        windowState.setViewId(facesContext.getViewRoot().getViewId());
      } catch (Exception e) {
        wrappedResponse.reset();
        log.log(Level.SEVERE, "Error processing execute lifecycle", e);
        exceptionHandler.processRenderException(facesContext,
            windowState, e);
      }
      // Set important Portal parameters to window state.
      String viewId = facesContext.getViewRoot().getViewId();
      //
      String actionURL = facesContext.getApplication().getViewHandler()
          .getActionURL(facesContext, viewId);
      actionURL = facesContext.getExternalContext().encodeActionURL(
          actionURL);
      windowState.setPortalActionURL(new PortalActionURL(actionURL));

      PortletURL portletURL = wrappedResponse.createRenderURL();
      portletURL.setParameter(PortletStateHolder.STATE_ID_PARAMETER,
          stateId.toString());
      String renderUrl = portletURL.toString();
      windowState.setPortalRenderURL(new PortalActionURL(renderUrl));
      windowState.setNamespace(namespace);
      windowState.setPortletLocale(request.getLocale());
      // TODO - encode request attributes, portlet mode and windowId, as
      // required by JSR-301 5.3.3
      String portletModeName = request.getPortletMode().toString();
      PortalActionURL historyViewId = new PortalActionURL(viewId);
      historyViewId.setParameter(PortletStateHolder.STATE_ID_PARAMETER,
          stateId.toString());
      historyViewId.setParameter(Bridge.PORTLET_MODE_PARAMETER,
          portletModeName);
      facesContext.getExternalContext().getSessionMap().put(
          VIEWID_HISTORY_PREFIX + portletModeName,
          historyViewId.toString());
      // writer.println("</div>");
      windowState.saveSeamConversationId(facesContext);
      // PortletSession portletSession = request.getPortletSession(true);
      PortletSession portletSession = (PortletSession) facesContext
          .getExternalContext().getSession(true);
      WindowIDRetriver idRetriver = (WindowIDRetriver) portletSession
          .getAttribute(PortletStateHolder.WINDOW_ID_RETRIVER);

      if (null != idRetriver) {
        windowState.setWindowId(idRetriver.getWindowID());
      }
      PortletBridgePrincipal security = new PortletBridgePrincipal(request,userRoles);
      // TODO - get user roles, defined in the portletbridge.xml ( ???
      // parse it ??? ), and store all values for a
      // "isUserInRole(roleName)" calls
View Full Code Here

      PortletBridgeContext bridgeContext = (PortletBridgeContext) context
          .getExternalContext().getRequestMap().get(
              PortletBridgeContext.REQUEST_PARAMETER_NAME);
      Map portletPreferencesMap = Collections.emptyMap();
      if (null != bridgeContext) {
        PortletWindowState windowState = bridgeContext.getWindowState();
        portletPreferencesMap = windowState
            .getPortletPreferencesMap();
      }
      return portletPreferencesMap;
    }
  }
View Full Code Here

   super.setUp();
   portletContext=new MockPortletContext(servletContext);
   portletRequest = new MockActionRequest(portletContext);
   portletResponse = new MockActionResponse();
   PortletStateHolder portletStateHolder = PortletStateHolder.init(new MockPortletContext(servletContext));
   PortletWindowState portletState = new PortletWindowState(){

  @Override
  public BridgeConfig getBridgeConfig() {
    return new BridgeConfig(){

      public Map<String, String> getDefaultViewIdMap() {
        HashMap<String, String> viewIdMap = new HashMap<String,String>();
        viewIdMap.put("view", "/foo.xhtml");
        return viewIdMap;
      }

      public Set<ExcludedRequestAttribute> getExcludedAttributes() {
        // TODO Auto-generated method stub
        return null;
      }

      public List<String> getFacesServletMappings() {
        // TODO Auto-generated method stub
        return null;
      }

      public String getInitParameter(String name) {
        // TODO Auto-generated method stub
        return null;
      }

      public PortletConfig getPortletConfig() {
        // TODO Auto-generated method stub
        return null;
      }

      public String getPortletName() {
        // TODO Auto-generated method stub
        return null;
      }

      public boolean isPreserveActionParams() {
        // TODO Auto-generated method stub
        return false;
      }

      public Map<Class<? extends Throwable>, String> getErrorPages() {
        // TODO Auto-generated method stub
        return null;
      }

         public Lifecycle getFacesLifecycle() {
            return null;
         }

      };
  }
    
   };
   portletStateHolder.addWindowState(STATE_ID, portletState);
   PortletBridgeContext bridgeContext = portletState.createBridgeContext();
   portletRequest.setAttribute(PortletBridgeContext.REQUEST_PARAMETER_NAME, bridgeContext);
   portletContextImpl = new PortletExternalContextImpl(portletContext,portletRequest,portletResponse);
   portalFacesContext = new FacesContextImpl(portletContextImpl,lifecycle);
   portalFacesContext.setViewRoot(facesContext.getViewRoot());
    }
View Full Code Here

     * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
     */
    public void setUp() throws Exception {
   super.setUp();
   PortletStateHolder portletStateHolder = PortletStateHolder.init(new MockPortletContext(servletContext));
   PortletWindowState portletState = new PortletWindowState(){

  @Override
  public BridgeConfig getBridgeConfig() {
    return null;
  }
View Full Code Here

   FacesContextFactoryImpl factory = new FacesContextFactoryImpl(facesContextFactory);
   MockPortletContext portletContext = new MockPortletContext(servletContext);
   MockActionRequest portletRequest = new MockActionRequest(portletContext);
   MockActionResponse portletResponse = new MockActionResponse();
   PortletStateHolder portletStateHolder = PortletStateHolder.init(new MockPortletContext(servletContext));
   PortletWindowState portletState = new PortletWindowState(){

  @Override
  public BridgeConfig getBridgeConfig() {
    return new BridgeConfig(){

      public Map<String, String> getDefaultViewIdMap() {
        HashMap<String, String> viewIdMap = new HashMap<String,String>();
        viewIdMap.put("view", "/foo.xhtml");
        return viewIdMap;
      }

      public Set<ExcludedRequestAttribute> getExcludedAttributes() {
        // TODO Auto-generated method stub
        return null;
      }

      public List<String> getFacesServletMappings() {
        // TODO Auto-generated method stub
        return null;
      }

      public String getInitParameter(String name) {
        // TODO Auto-generated method stub
        return null;
      }

      public PortletConfig getPortletConfig() {
        // TODO Auto-generated method stub
        return null;
      }

      public String getPortletName() {
        // TODO Auto-generated method stub
        return null;
      }

      public boolean isPreserveActionParams() {
        // TODO Auto-generated method stub
        return false;
      }

      public Map<Class<? extends Throwable>, String> getErrorPages() {
        // TODO Auto-generated method stub
        return null;
      }

         public Lifecycle getFacesLifecycle() {
            return null;
         }

      };
  }
    
   };
   portletStateHolder.addWindowState(STATE_ID, portletState);
   PortletBridgeContext bridgeContext = portletState.createBridgeContext();
   portletRequest.setAttribute(PortletBridgeContext.REQUEST_PARAMETER_NAME, bridgeContext);
   FacesContext context = factory.getFacesContext(portletContext,
      portletRequest, portletResponse, lifecycle);
   assertTrue((context instanceof FacesContextImpl));
   assertTrue((context.getExternalContext() instanceof AbstractExternalContext));
View Full Code Here

    PhaseId phaseId = event.getPhaseId();
    FacesContext context = event.getFacesContext();
    Object portletPhase = context.getExternalContext().getRequestMap().get(
        Bridge.PORTLET_LIFECYCLE_PHASE);

    PortletWindowState windowState = null;
    PortletBridgeContext bridgeContext = (PortletBridgeContext) context
        .getExternalContext().getRequestMap().get(
            PortletBridgeContext.REQUEST_PARAMETER_NAME);
    if (null != bridgeContext) {
      windowState = bridgeContext.getWindowState();
    }

    if (phaseId.equals(PhaseId.RESTORE_VIEW)) {
      if (Bridge.PortletPhase.RenderPhase.equals(portletPhase)) {
        context.renderResponse();
      }

    } else if (phaseId.equals(PhaseId.RENDER_RESPONSE)) {
      // save Seam conversation Id.
      if (null != windowState) {
        windowState.saveSeamConversationId(context);
      }

    }

  }
View Full Code Here

        Bridge.PORTLET_LIFECYCLE_PHASE);
    if (null == portletPhase && phaseId.equals(PhaseId.RENDER_RESPONSE)) {
      // For a servlet phase, put all portletbridge-related parameters
      // back to ajaxContext.

      PortletWindowState windowState = null;
      PortletBridgeContext bridgeContext = (PortletBridgeContext) context
          .getExternalContext().getRequestMap().get(
              PortletBridgeContext.REQUEST_PARAMETER_NAME);
      if (null != bridgeContext) {
        windowState = bridgeContext.getWindowState();
      }

      if (null != ajaxContext && null != windowState) {
        Map commonAjaxParameters = ajaxContext.getCurrentInstance(
            context).getCommonAjaxParameters();

        PortalActionURL pal = windowState.getPortalActionURL();
        if (null != pal) {
          pal.setParameter(AbstractExternalContext.VIEW_ID_PARAMETER,
              context.getViewRoot().getViewId());
        }
        commonAjaxParameters.put(PortletStateHolder.STATE_ID_PARAMETER,
            bridgeContext.getStateId().toString());
        commonAjaxParameters.put(
            AjaxPortletBridge.AJAX_NAMESPACE_PARAMETER, windowState
                .getNamespace());

      }
    }
  }
View Full Code Here

         // save Seam conversation Id.
      PortletBridgeContext bridgeContext = (PortletBridgeContext) facesContext
          .getExternalContext().getRequestMap().get(
              PortletBridgeContext.REQUEST_PARAMETER_NAME);
      if (null != bridgeContext) {
        PortletWindowState windowState = bridgeContext.getWindowState();
        windowState.saveSeamConversationId(facesContext);
      }
         _defaultListener.afterResponseComplete(facesContext);
      }

   }
View Full Code Here

TOP

Related Classes of org.jboss.portletbridge.application.PortletWindowState

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.