4 Replies Latest reply on Oct 12, 2008 7:51 AM by danielk

    PortalURL call with an action possible?

    danielk

      Hi,

      just a short question. Is it possible to make a call of a portal url (for example /portal/portal/myownpage/subpage) within an actionListener call?

      Example:
      index.jsp

      <h:commandLink actionListener="#{myBean.callRenderUrl}">
       <h:outputText value="Click me!" />
      </h:commandLink>


      MyBean.java:
      public void callRenderUrl(ActionEven event) {
       // make a redirect to url - do not know how :((
       response.callUrl()?
      }


      I want to use this kind of this stuff, instead of a link in my portlet. Has someone a hint for me?

        • 1. Re: PortalURL call with an action possible?
          alexsmirnov

          Portlet specification allowed redirects at the action phase. Bridge CxternalContext.redirect() method should delegate this call to the appropriate portlet method. This is a scratch for the your action method :

          public void callRenderUrl(ActionEven event) {
           FacesContext context = event.getFacesContext();// or FacesContext.getCurrentInstance();
           ExternalContext externalContext = context.getExternalContext();
           String url = .... // construct your redirection URL.
           externalContext.redirect(url);
           context.responseComplete();
          }


          • 2. Re: PortalURL call with an action possible?
            danielk

            I think thats exactly what i am searching for. Thanks for your help, i will try it.

            • 3. Re: PortalURL call with an action possible?
              danielk

               

              public void callRenderUrl(ActionEven event) {
              FacesContext context = event.getFacesContext();// or FacesContext.getCurrentInstance();
              ExternalContext externalContext = context.getExternalContext();
              String url = .... // construct your redirection URL.
              externalContext.redirect(url);
              context.responseComplete();
              }


              Is not working, if you are using Richfaces with JBoss Portal, because if you call externalContext.redirect(absoluteURL) or ((JBossActionResponse) response).sendRedirect(portalURL) Exception will be thrown, because in this phase setPortletMode was already called. I can post the correct exception here tomorrow, if this helps. But my problem is still there, how can i redirect from my action or actionListener (addActionListener() and setActionExpression() both tried) to a portal page?

              Or is it impossible?

              Thanks for reading and perhaps answering my question,

              DanielK

              PS: Background, PanelMenuItem with links is not really cute, because of parts where you can click at, but "nothing" happens (you will only will be redirected to the same portal page). Only if you click at one link into one of these PanelMenuItems, another portal page will be showed.

              <rich:panelMenu event="onclick" submitMode="none">
               <rich:panelMenuItem label="Link to external page">
               <h:outputLink ... >
               <rich:panelMenuItem>
               </rich:panelMenu>


              Example from:
              http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html/panelMenu.html

              Not really good, because only outputLink will be usable, like i described above :((

              • 4. Re: PortalURL call with an action possible?
                danielk

                Ok, two pages ahead i found the solution for my problem:

                <rich:panelMenu>
                 ...
                 <rich:panelMenuItem submitMode="none" onclick="document.location.href='http://labs.jboss.com/jbossrichfaces/">
                 <h:outputLink value="http://labs.jboss.com/jbossrichfaces/">
                 <h:outputText value="RichFaces Home Page"></h:outputText>
                 </h:outputLink>
                 </rich:panelMenuItem>
                 ...
                 </rich:panelMenu>


                Its important to use submitMode="none" and i had to use links twice (outputLink and onclick event), perhaps because of 2 different phases? Is not 100% what i want, but perhaps its not possible to make a redirect from actions or actionListeners?