Package javax.portlet.faces

Examples of javax.portlet.faces.BridgeException


    if (null != errorPage) {
      windowState.reset();
      setupErrorParameters(context,errorPage.getException());
      windowState.setViewId(errorPage.getLocation());
    } else {
      throw new BridgeException("Error processing render lifecycle", e);
    }

  }
View Full Code Here


      UIViewRoot root = context.getApplication().getViewHandler().createView(context, errorPage.getLocation());
      setupErrorParameters(context, errorPage.getException());
      context.setViewRoot(root);
      windowState.getBridgeConfig().getFacesLifecycle().render(context);
    } else {
      throw new BridgeException("Error processing render lifecycle", e);
    }
  }
View Full Code Here

      if(modeEnd >modeStart){
        scopeId = stateId.substring(0, modeStart);
        mode = new PortletMode(stateId.substring(modeStart+1, modeEnd));
        uuid = stateId.substring(modeEnd+1);
      } else {
        throw new BridgeException("Invalid StateId format");
      }
    } else {
      throw new BridgeException("Invalid StateId format");
    }
  }
View Full Code Here

         }
         catch (Exception ehe)
         {
            try {
               //todo - there is an evaluation problem when trying to handle with Seam exception handler
               throw new BridgeException(ehe);
            } catch (BridgeException e1) {
               messageList.add(new FacesMessage("Unable to process with Seam exception handler",""));
               log.error("throwing new BridgeException was unsuccessfull");
               e1.printStackTrace();
            }
View Full Code Here

  public void init(PortletConfig config)
    throws BridgeException
  {
    //TODO: Should we throw an exception if the bridge is already initialized?
    if (mInitialized)
      throw new BridgeException("Bridge already initialized.");

    mPortletConfig = config;
    PortletContext portletContext = mPortletConfig.getPortletContext();
   
    // acquire any config information in faces-config.xml
    FacesConfigurationProcessor processor = new FacesConfigurationProcessor(portletContext);
    mPublicParameterMappings = processor.getPublicParameterMappings();
   
    // get bridgeEventHandler, processPublicRenderParameterHandler, preserveActionParams, excludedAttributes configuration settings.
    mEventHandler = (BridgeEventHandler) portletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName() +
                                              "." + Bridge.BRIDGE_EVENT_HANDLER);
   
    mProcessPRPHandler = (BridgePublicRenderParameterHandler) portletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName() +
                                              "." + Bridge.BRIDGE_PUBLIC_RENDER_PARAMETER_HANDLER);
    mPreserveActionParams =
        (Boolean) portletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName() +
                                              "." + Bridge.PRESERVE_ACTION_PARAMS);

    mExcludedRequestAttributes = (List<String>) portletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName() +
                                                      "." + Bridge.EXCLUDED_REQUEST_ATTRIBUTES);
    if (mExcludedRequestAttributes != null)
    {
      // copy the list as we may be adding to it and don't want to worry that this might be immutable
      mExcludedRequestAttributes = new ArrayList(mExcludedRequestAttributes);
    }
    else
    {
      // Otherwise create an empty list
      mExcludedRequestAttributes = new ArrayList(5);
    }

    // Read excludedAttributes that may be defined in any face-config.xml
    readExcludedAttributesFromFacesConfig(portletContext, mExcludedRequestAttributes);

    // Set up the synchronziation object for the RequestScopeMap as we don't
    // want to sync on the PortletContext because its too broad. Note:
    // needed
    // because we not only need to sync the Map but also creating the Map
    // and
    // putting it in the PortletContext. Hence the sync object allows us
    // to limit syncronizing the PortletContext to once per portlet (init
    // time);

    // TODO: What about synching on a static object or using a class lock?
    //       Perhaps even the LRUMap itself if said map is a singleton?
    synchronized (portletContext)
    {
      Object lock = portletContext.getAttribute(REQUEST_SCOPE_LOCK);
      if (lock == null)
      {
        portletContext.setAttribute(REQUEST_SCOPE_LOCK, new Object());
      }
    }

    // Add self as ELContextListener to the Faces App so we can add the
    // portletConfig to any newly created contexts.
    ApplicationFactory appFactory =
      (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    Application app = appFactory.getApplication();
    app.addELContextListener(this);

    // Process and cache the FacesServlet mappings for use by
    // ExternalContext
    WebConfigurationProcessor webConfig = new WebConfigurationProcessor(portletContext);
    mFacesMappings = webConfig.getFacesMappings();
    if (mFacesMappings == null || mFacesMappings.size() == 0)
    {
      throw new BridgeException("BridgeImpl.init(): unable to determine Faces servlet web.xml mapping.");
    }

    // Set defaults for each mode's last active view session attribute
    mDefaultViewIdMap = (Map<String,String>) portletContext.getAttribute(
                                Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName()
View Full Code Here

    {
      mPortletConfig.getPortletContext().log("Exception thrown in doFacesRequest:action", e);
      if (!(e instanceof BridgeException))
      {
        Throwable rootCause = e.getCause();
        throw new BridgeException(e.getMessage(), rootCause);
      }
      else
      {
        throw (BridgeException) e;
      }
View Full Code Here

    {
      mPortletConfig.getPortletContext().log("Exception thrown in doFacesRequest:action", e);
      if (!(e instanceof BridgeException))
      {
        Throwable rootCause = e.getCause();
        throw new BridgeException(e.getMessage(), rootCause);
      }
      else
      {
        throw (BridgeException) e;
      }
View Full Code Here

      mPortletConfig.getPortletContext().log("Exception thrown in doFacesRequest:render", e);
      if (!(e instanceof BridgeException))
      {
        Throwable rootCause = e.getCause();
        throw new BridgeException(e.getMessage(), rootCause);
      }
      else
      {
        throw (BridgeException) e;
      }
View Full Code Here

        }
      }
    }
    else
    {
      throw new BridgeException("Shouldn't get here -- disabled cached restore.");
    }


    // check here to see if a redirect occurred -- if so rerun doFacesRequest
    // for this new view
View Full Code Here

      catch (Exception e)
      {
        if (!(e instanceof BridgeException))
        {
          Throwable rootCause = e.getCause();
          throw new BridgeException(e.getMessage(), rootCause);
        }
        else
        {
          throw (BridgeException) e;
        }
      }
    }

    // Otherwise this is a Faces resource
   
    // must wait until after init to get at the session
    // since view mode mapping must always exist -- check it
    StringBuffer keyBuf = new StringBuffer(30);
    String key = keyBuf.append(Bridge.VIEWID_HISTORY).append(".view").toString();
    if (request.getPortletSession().getAttribute(key) == null)
    {
      initViewHistoryDefaults(request.getPortletSession(), mDefaultViewIdMap);
    }
   

    // Set the PortletName for use throughout this request to read portlet specific context attrs
    request.setAttribute(PORTLET_NAME_ATTRIBUTE, mPortletConfig.getPortletName());


    // Set the FacesServletMapping attribute so the ExternalContext can
    // pick it up and use it to reverse map viewIds to paths
    if (mFacesMappings != null)
    {
      request.setAttribute(PortletExternalContextImpl.FACES_MAPPING_ATTRIBUTE, mFacesMappings);
    }

    // cache names of existing request attributes so can exclude them
    // from being saved in the bridge's request scope. Note: this is done
    // before
    // acquiring the FacesContext because its possible (though unlikely)
    // the application has inserted itself in this process and sets up
    // needed request attributes.
    List<String> preExistingAttributes = getRequestAttributes(request);
    // place on the request for use here and in the servletRequestAttributeListener
    if (preExistingAttributes != null)
    {
      request.setAttribute(PREEXISTING_ATTRIBUTE_NAMES, preExistingAttributes);
    }

    String scopeId = getRequestScopeId(request);
    if (scopeId == null)
    {
      // first request is a resource request
      // create a scope and store in the session until an action occurs
      // pass null as we aren't a StateAwareResponse
      scopeId = initBridgeRequestScope(request, null);
    }

    FacesContext context = null;
    try
    {
      // Get the FacesContext instance for this request
      Lifecycle lifecycle = getLifecycle();
      context =
          getFacesContextFactory().getFacesContext(mPortletConfig, request, response, lifecycle);
      ExternalContext extCtx = context.getExternalContext();

      // Use request from ExternalContext in case its been wrapped by an
      // extension
      ResourceRequest extRequest = (ResourceRequest) extCtx.getRequest();

      // Ensure the ContentType is set before rendering
      if (extCtx.getResponseContentType() == null)
      {
        response.setContentType(extRequest.getResponseContentType());
      }

      // ensure that isPostback attribute set if VIEW_STATE param exists
      if (extCtx.getRequestParameterValuesMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM))
      {
        extCtx.getRequestMap().put(Bridge.IS_POSTBACK_ATTRIBUTE, Boolean.TRUE);
      }

      doFacesRender(request, response, context, lifecycle, scopeId, preExistingAttributes);
    }
    catch (Exception e)
    {
      // When exception occurs remove stored scope so don't
      // get stuck replaying the error when/if user refreshes
      if (scopeId != null)
      {
        removeRequestScopes(scopeId);
      }

      context.getExternalContext().log("Exception thrown in doFacesRequest:render", e);
      if (!(e instanceof BridgeException))
      {
        Throwable rootCause = e.getCause();
        throw new BridgeException(e.getMessage(), rootCause);
      }
      else
      {
        throw (BridgeException) e;
      }
View Full Code Here

TOP

Related Classes of javax.portlet.faces.BridgeException

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.