-
1. Re: Navigation outcome from bean
quilleashm Feb 16, 2007 8:23 AM (in response to hamtho2)http://docs.jboss.com/seam/1.1.6.GA/reference/en/html/events.html
See the section on navigation. -
2. Re: Navigation outcome from bean
hamtho2 Feb 16, 2007 8:53 AM (in response to hamtho2)Thank you very much for that. I totally overlooked that part. But it´s still neccessary to have a view-id that is a real xhtml-page. There´s no way to use the outcome of a bean-action for multiple pages, is there? So that I could use the outcome of an action for multiple pages?
Thomas -
3. Re: Navigation outcome from bean
quilleashm Feb 16, 2007 9:10 AM (in response to hamtho2)I'm not quite understanding the question.
The view-id in pages.xml does not have to be a real page, it can just be to bind an action that is executed when that view is requested but then the action can return an outcome which the page navigation uses to render a different page. -
4. Re: Navigation outcome from bean
hamtho2 Feb 16, 2007 9:20 AM (in response to hamtho2)sorry - I really did not explain it really clearly.
The idea is the following:
I have two different xhtml-pages with an command button on each page referencing to the same ActionBean and calling the same methods, but the result of that action always points to the same result-page. So is it possible to define that whenever this bean is called - doesn´t matter from what page - it should redirect to a defined outcome with only one definition in the pages.xml or navigation.xml? -
5. Re: Navigation outcome from bean
quilleashm Feb 16, 2007 9:32 AM (in response to hamtho2)Try..
<page view-id="/*"> <navigation from-action="#{myBean.commonAction}"> <rule> <redirect view-id="/results.xhtml"/> <rule/> </navigation-case> </navigation-rule>
Haven't tried this myself but I think this should work. Basically this says for any page if the "myBean.commonAction" was the action method fired (and it returned a not-null result) by the button click then change the view to the "/results.xhtml" view. The wildcarding is suffix matching so you can make it more specific if you wish.
Let me know if this works pls, be useful for future reference.
HTH.
Mike. -
6. Re: Navigation outcome from bean
fernando_jmt Feb 16, 2007 9:39 AM (in response to hamtho2)Some corrections for the last sample source code:
<page view-id="/*"> <navigation from-action="#{myBean.commonAction}"> <redirect view-id="/results.xhtml"/> </navigation> </page>
-
7. Re: Navigation outcome from bean
quilleashm Feb 16, 2007 10:32 AM (in response to hamtho2)I believe both code samples are above are valid but they do different things. The first will only do the re-direct if the action method returns not-null. The second only if the method returns null. I'm not sure which of these the void case falls into but I suspect the second one.
-
8. Re: Navigation outcome from bean
quilleashm Feb 16, 2007 10:33 AM (in response to hamtho2)Sorry I just spotted the closing </navigation-rule> in my sample which is of course wrong. I'd love to take the blame but I copy-pasted from the Seam docs ;)
-
9. Re: Navigation outcome from bean
hamtho2 Feb 16, 2007 10:34 AM (in response to hamtho2)Mike,
your idea came pretty close to how it works. Thanks for your help.
This is it worked for me now:<page view-id="/*"> <navigation from-action="#{myBean.commonAction}"> <redirect view-id="/results.xhtml"/> </navigation> </page>
But do you know if it is possible to redirect to the page, where I came from as well? If I call an action-method and it returns a String with null, I will be redirected to the page I came from automatically. So is there a way to define this through the pages definition as well?
I thought about something like this:<navigation> <rule if="#{myBean.anotherAction}"> <redirect view-id="/successfull.xhtml"/> </rule> <rule if="#{not myBean.anotherAction}"> <redirect view-id="null"/> <!-- Should be the calling page then --> </rule> </navigation>
Is there a way to do something like a switch-case if there might be different-results? In the code-example mentioned above, the anotherAction is probably called everytime I have a new rule.
DO you know anything about this? -
10. Re: Navigation outcome from bean
hamtho2 Feb 16, 2007 10:39 AM (in response to hamtho2)sorry - I didn´t refresh the thread before posting. I guess you already told the solution through your explanation. I´ll try this first.
-
11. Re: Navigation outcome from bean
hamtho2 Feb 16, 2007 11:21 AM (in response to hamtho2)Yes - it seems, that it works that way. If a null value is returned, I will be redirected to the page I came from if I include the -Tag
Thanks for that