8 Replies Latest reply on Jul 4, 2006 2:01 AM by norman.richards

    How to retrieve current view ?

    jboss-nth-fan

      After navigating with a Link or by using a PageFlow, how can I retrieve the value of the current view in both the newly rendered page itself and inside an action ?

      <s:link view="/myView.xhtml" >




        • 1. Re: How to retrieve current view ?
          gavin.king

          You mean you want to discover the current JSF viewId?

          • 2. Re: How to retrieve current view ?
            jboss-nth-fan

            Thanks for your almost quick response Gavin, great support !

            I'm thinking if the JSF viewId would be the correct way to access it or does Seam store that reference or handler somewhere else?
            If so how should I access it: standard JSF or via a Seam method ?

            Yeyo.

            • 3. Re: How to retrieve current view ?
              gavin.king

              Just the standard JSF way: facesContext.getViewRoot().getViewId()

              • 4. Re: How to retrieve current view ?
                jboss-nth-fan

                Thanks Gavin.

                Maybe a bit off topic , but in the DVD sample in the login.xhtml page I've modified in my own prototype to use s:link instead of the

                <h:commandLink action="#{editCustomer.startEdit}">Create Account</h:commandLink>

                but did not work. I had the idea that both commandLink and s:Link would be somewhat interchangable but it seems not.

                Can you point to resources providing insight on the differences?

                Thanks


                • 5. Re: How to retrieve current view ?
                  gavin.king

                  No, they are not interchangeable. s:link does _not_ submit the form!

                  • 6. Re: How to retrieve current view ?

                    That's actually not the issue here though. The difference here is that the h:commandLink action executes during the normal invoke application phase. With an s:link action, the action executes during as a page event during the render response phase.

                    If a pageflow starts during the invoke application, it should start with a start-node. When started from ender response, it needs to begin with a start-page. This is somewhat awkward because you have to make sure that you are on the correct starting view. (s:link should contain both a view and an action attribute)

                    Hope that helps.

                    • 7. Re: How to retrieve current view ?
                      gavin.king

                      I can treat pageflows that start from a page action the same as pageflows that start during INVOKE_APPLICATION if you think that would be more natural/correct, Norman. But the idea is that page actions do not _usually_ change the view id, so you are already at the start-page when the action is called...

                      • 8. Re: How to retrieve current view ?

                        I was just pointing out the difference with regards to the way things are implemented now and why the two styles of invocation didn't act the same with regard to pageflow. I didn't understand the distinction myself until we talked about it a month or two ago, and so I definitely think most users would be confused by this.

                        I *think* I would prefer the the page action and invoke application action to work the same for pageflows, but even if they are different, I would expect an s:link action to work like an h:commandLink action.

                        Maybe some other Seam users here can comment on what they feel is more natural.