3 Replies Latest reply on Aug 22, 2011 1:33 AM by Ismail Jaliawala

    How to redirect a page from a JSF portlet

    Jorge Ferreyra Newbie

      Hello, and thanks for your answers.

      I've implemented the communication between JSF portlets through PRP, this is OK when I put the portlets in the same page of the portal, but my aim is to place the portlets in different pages, so when I do click in a commandLink, the portlet A pass the parameter to a portlet 'B' and redirect the page where this portlet 'B' is.

       

       

      Portlet 'A' (page 1):

       

      home.xhtml:

      <h:form>
           <c:forEach var="elem" items="#{myBean.anArrayOfNews}"> 
                <h:commandLink action="#{myBean.comunicate}" value="COMENT">
                     <f:param name="id" value="#{elem.id}"/> 
      
                </h:commandLink>
           </c:forEach>
      </h:form>
      

       

      myBean.java:

       public String comunicate(){
       try{
            FacesContext context = FacesContext.getCurrentInstance();
            PortletRequest request = (PortletRequest)context.getExternalContext().getRequest();
            String parameter = request.getParameter("id");
            Object response = FacesContext.getCurrentInstance().getExternalContext().getResponse();
            if (response instanceof StateAwareResponse) {
                 StateAwareResponse stateResponse = (StateAwareResponse)response;
                 stateResponse.setRenderParameter("prp",parameter);
            }
       }catch (Exception e) {
            e.printStackTrace();
       }
       return null;
       }
      

       

       

      Portlet 'B' (page 2):

       

      myBean.java

       

       try{
            FacesContext context = FacesContext.getCurrentInstance();
            PortletRequest request = (PortletRequest)context.getExternalContext().getRequest();
            String parameter = request.getParameter("prp");
            if(parameter!=null){
                 id = Integer.parseInt(parameter);
            }
       }catch (Exception e) {
            e.printStackTrace();
       }
      

       

      The question is: how do I redirect to the page 2, when i do click in the <h:commandLink> ?

       

      I'm using GateIn Portal 3.0 GA , JBoss Portlet Bridge 2.0 RC