11 Replies Latest reply on Nov 1, 2012 6:36 PM by kchintoju

    How to redirect to external URL in pages.xml?

    benmoore

      Hi,


      In pages.xml, how can I redirect to an external URL? It appears that <redirect /> only allows view-id, not an external URL. Is there another way to do this in pages.xml?


      thanks,
      ben

        • 1. Re: How to redirect to external URL in pages.xml?
          christian.bauer

          Didn't you ask the same question three weeks ago? I remember answering this at least twice already. Or, you could just look at the schema (I know, difficult to open with a text editor...).

          • 2. Re: How to redirect to external URL in pages.xml?
            benmoore

            My previous question was how to redirect to an external URL from an action in the Seam way (not using FacesContext). The answer to that was to use FacesManager.instance().redirectToExternalURL(url) if using trunk (it's not in the GA releases yet).


            This question is slightly different: how to redirect to an external URL from pages.xml, not from an action. And yes, I've looked thoroughly at the XSD.

            • 3. Re: How to redirect to external URL in pages.xml?
              benmoore

              The xsd only shows view-id as possible attributes of <redirect/>. What am I missing?

              • 4. Re: How to redirect to external URL in pages.xml?
                christian.bauer

                pages-2.1.xsd

                • 5. Re: How to redirect to external URL in pages.xml?
                  csaho

                  Hello!


                  Try something like this:



                  <page view-id="/someView.xhtml">
                      <action execute="#{ facesContext.externalContext.redirect( 'www.jboss.org' ) }" />
                  </page>


                  • 6. Re: How to redirect to external URL in pages.xml?
                    accountclosed

                    It appears that 2.1 of the pages.xsd now contains a url attribute for the redirect element so, in theory, one could say something like this:



                    <page view-id="/purchaseproduct.xhtml" 
                       conversation-required="true" scheme="https">
                       <restrict>#{purchasesession.started}</restrict>
                       <navigation 
                         from-action="#{purchasesession.submitpurchase}">
                         <redirect url="#{purchasesession.getURL}"/>
                         <!-- Where #{purchasesession.getURL} could be
                              something like:
                      http://www.onlineservice.com/mycompany?id=123&custid=456
                          -->
                      </navigation>
                    </page>



                    I say in theory because I've never used this before. :)

                    1 of 1 people found this helpful
                    • 7. Re: How to redirect to external URL in pages.xml?
                      benmoore

                      cool. which version of seam do i need for pages-2.1.xsd to be supported? Will it only work in Seam 2.1? and above?

                      • 8. Re: How to redirect to external URL in pages.xml?
                        accountclosed

                        I'm hedging a guess that it's 2.1 and up since that attribute is not found in the pages.xsd of 2.0.x. You could always put that attribute in there and run it with 2.0.3 and see if it spews exceptions.

                        • 9. Re: How to redirect to external URL in pages.xml?
                          didier

                          Bonjour,


                          If you write this :



                          <page view-id="/someView.xhtml">
                              <action execute="#{facesContext.externalContext.redirect('http://www.jboss.org')}" />
                          </page>



                          It works fine.


                          Thank you, it helps me.

                          • 10. Re: How to redirect to external URL in pages.xml?
                            coldgin

                            Thanks, Didier. That config example helped me out a lot.

                            • 11. Re: How to redirect to external URL in pages.xml?
                              kchintoju

                              I know this is an old article but this is on top when looking pages.xml redirect options in google.

                               

                              <page view-id="/some-view.xhtml">

                                                  <action execute="#{bean.action()}" />

                                                  <navigation>

                                                            <rule if-outcome="true">

                                                                      <redirect url="#{bean.url}" />

                                                            </rule>

                                                            <rule if-outcome="false">

                                                                      <redirect view-id="/error/error.xhtml">

                                                                                <message>#{bean.message}</message>

                                                                      </redirect>

                                                            </rule>

                                                  </navigation>

                              </page>

                              1 of 1 people found this helpful