5 Replies Latest reply on Jan 12, 2009 8:36 PM by stephen

    Easy way to render a different view?

    stephen

      I have a general view /todo.xhtml as a stand-in for parts of the application that are still missing.
      However I want the URLs/view ids for the missing parts to already work.
      For example currently the application's home page isn't done yet, so I have this in my pages.xml and can already use /home.xhtml in my app (say a navigation bar):


      <page view-id="/home.xhtml" login-required="true" action="#{elUtil.nullAction}">
          <rewrite pattern="/home"/>
          <navigation from-action="#{elUtil.nullAction}">
              <render view-id="/baustelle.xhtml"/>
          </navigation>
      </page>
      



      Is there a nicer/cleaner/better way to do that without using a dummy action?

        • 1. Re: Easy way to render a different view?
          dhinojosa

          Use urlrewrite that comes with seam

          • 2. Re: Easy way to render a different view?
            stephen

            Thanks for the answer. That won't really be less work. I was hoping that I have overlooked something in the pages.xml syntax.
            Don't you think that's a common request - just render or redirect somewhere else?


            More importantly I am not sure if the urlrewrite approach will work: How can I rewrite outbound occurences of /baustelle.xhtml to different view-ids (if I use my temporary /baustelle.xhtml at several pages)?


            I can live with the slightly strange construct of calling a dummy page action just to get a navigation hook, it's just something that doesn't feel right.

            • 3. Re: Easy way to render a different view?
              norman

              Your nullAction could return to the new view-id if you preferred.  That reduces the XML Or, if you just always want to trigger the new view, just make the view-id the action:



              <page view-id="/home.xhtml" action="/baustelle.xhtml" />
              

              • 4. Re: Easy way to render a different view?
                dhinojosa

                Well, rendering and redirecting is a common request, but for pages that don't exist yet?  Maybe not, whatever floats your boat.  I would just use my handy 404 page, but it looks like Norman's solution is probably what you are looking for.

                • 5. Re: Easy way to render a different view?
                  stephen

                  But that will navigate to the new view, right?
                  I'd like the URL to stay like it is, so that for example the selenium test that checks if a user is redirected to the home page after successful login can already be written and runs fine.


                  IMHO such virtual views really are quite common. They could also be old pages where I'd like the URL to stay valid.


                  Another example is an action invalidate-session.xhtml that I use for testing proper handling of session time-outs: I invoke the URL in one browser tab to kill the session, then in another browser tab try to use the session. (Else I would need to change my web.xml for testing to have a session timeout of 1 minute, then wait at least that long until the container really removes the session. Also my Selenium tests need this hook.)