2 Replies Latest reply on Mar 10, 2008 10:11 PM by Bojan R

    Redirection Question

    Bojan R Newbie

      I know there's a lot of questions about redirection, but I have one that I have not noticed being asked before, at least not in this way.
      When you first load

      http://localhost:8080/myapp/

      it goes to index.html which has
      <meta http-equiv="Refresh" content="0; URL=home.seam">

      so the first page shown is home.xhtml.
      What I would like to do is have login.xhtml be the page that loads when
      http://localhost:8080/myapp/

      is loaded. If I simply put login.seam in HTTP refresh in index.html, then when a user is logged in and backspaces the URL in address bar to app's root, he or she would be mistakenly taken to the login page. However, if the user is logged in, then a user's default page should be loaded when the app's root URL is loaded.
      I have played with pages.xml and individual .page.xml files but have not found a combination that would produce the desired result.
      Any suggestions as to how to go about doing this?
      Thanks!

        • 1. Re: Redirection Question
          Keith Naas Novice

          Something like this?


          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib">
          <head>
          <!-- users who are authorized for the homepage are sent to the homepage.  
               unauthorized are logged out and sent back to login since we have to put them somewhere. -->
          <s:fragment rendered="#{identity.loggedIn}">
              <meta http-equiv="Refresh"
                  content="0; URL=#{facesContext.externalContext.requestContextPath}#{org.jboss.seam.core.pages.noConversationViewId}" />
          </s:fragment>
          <s:fragment rendered="#{not identity.loggedIn}">
              <meta http-equiv="Refresh"
                  content="0; URL=#{facesContext.externalContext.requestContextPath}#{org.jboss.seam.core.pages.loginViewId}?actionMethod=index.xhtml%3Aidentity.logout&amp;conversationId=#{conversation.id}" />  
          </s:fragment>
          </head>
          <body>
              <s:link action="#{identity.logout}" view="#{org.jboss.seam.core.pages.loginViewId}"/>
          </body>
          </html>
          



          This was for Seam 1.2.1.GA on an app running in production.  Things are probably just a little different in Seam 2.

          • 2. Re: Redirection Question
            Bojan R Newbie

            Yes, something like that. I am using 2.0.1-GA. I put something similar into index.xhtml and when invoked, the URL shows the actual  EL, not redirecting properly. I am not quite sure whether it has to do with the version or me simply missing something.