I have been some time trying to get page navigation going when I want to pass parameters to the target page. I note that there are already some threads that cover this both in this forum and on the web in general. However, as a subject that is tackled head on by the more formal forums (Sun tutorials, books, etc) it seems to be over looked or at best glossed over.
I have however, finally had some success and thought I would share it here because a) someone else might find my experience useful and b) you may have some insight you can provide c) I think there is a problem either with JSF in general or the implementation I have chosen (my-faces) and would value any ones own experience here.
Here?s my code in the pages I want to navigate from
..
<h:commandLink action="go_to_work" immediate="true">
<f:param name="mode" value="bus" />
...
Where my jsf config file has the following navigation rule for 'go_to_work'...
...
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>go_to_work</from-outcome>
<to-view-id>/work.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
....
Note that
<redirect/> tag. In the end that was what was causing me problems. Remove that and you can then reference the ?mode? parameter as a normal page parameter.
For example both will work:
<h1>You came to work by ${param.mode}</h1>
<h1>You came to work by <h:outputText value="#{param.mode}" /></h1>
...
So getting back to why I posted this
a) if you want to send parameters when you request a page then
DO NOT use <redirect/> in your navigation-rule
b) Or have I got this wrong and there are other ways????
c) If I have not got this wrong then we have a problem, because <redirect/> is a very desirable option. Without it the URL in the Browser does not change and I have some confused users. Or perhaps is it my-faces that has this wrong.