1 Reply Latest reply on Apr 2, 2007 10:33 AM by Stan Silvert

    JSF and Portal

    kreilly Newbie

      In my portlet's edit mode, I let a user make some configuration selections. This is done using JSF. When the user submits the form, I would like to save that data using the PortalPreferences object. The problem I'm having is with JSF, I do not have a request object when my form is submitted (a plain method off a managed bean is called). Without a request object I can not get to the PortalPreferences object for this user. So my question is:

      How do I get to JSF managed beans from the actionPerformed method?


      How do I get a request object from a method managed by JSF?

      Or, if you know of a better way to handle JFS/Portal edit mode, feel free to offer suggestions.


        • 1. Re: JSF and Portal
          Stan Silvert Master

          Using modes with JSF is a research topic at this point. There is no agreement on the best way to do it. Here is one approach: http://wiki.apache.org/myfaces/UsingPortletModes

          You can get the request object by calling FacesContext.getExternalContext().getRequest(). You should check to make sure that you can cast to the PortletRequest if you think your code will be used outside a portlet. If you are using the MyFaces portlet bridge, see http://wiki.apache.org/myfaces/UsingPortletUtil

          Also, you can access managed beans using the EL.

          String value = (String)facesContext.getApplication()

          If you are outside the JSF lifecycle, you won't have access to the FacesContext. In this case, you need to get the Application object from the ApplicationFactory.

          ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
          Application app = appFactory.getApplication();