I'm looking for a way to send parameters to another view when I'm changing the view in Java - not in the JSF markup.
For example, I know I can pass params to another view using this in JSF:
Then using the managed-property option of my managed bean definition to grab that param and put it in that bean.
So my question is now - how do I do that from straight Java? I have a command link that has an action listener that needs to perform some actions to get the param values, then I want to put those values on the request to the next view. I'm using the getNavigationHandler().handleNavigation method of the facescontext to send it on to that same view called "viewer".
I've tried things like this:
before calling the handleNavigation method.. but that doesn't work.
JSF is as about close as you can get to true MVC within the limitations of the HTTP protocol. That means that it's not really a good idea to try and treat it like you would traditional Java HTTP platforms such as servlet/JSP or Struts.
In your case, the operative elements are a need to understand that JSF doesn't so much serve page requests as it does present a View and converse with that view until a request is made requiring a different View. Related to that is a problem that a lot of people complain about - JSF URLs don't directly correspond to their displayed Views, since their purpose is to maintain a context, not request a page.
If you try to brute-force push Views around, your code will be unnecessarily complex and unreliable. Part of the beauty of JSF is that a well-designed JSF app will have very little java.faces class references in it. Most everything (except datamodels) can be done with POJOs.
Thus, the way you generally "pass parameters to a view" is to set properties in one or more of the backing beans that the new view will reference, then set up a navigation rule on your commandLink that will cause that new view to be displayed. Because you can inject properties in JSF (Inversion of Control), you may find that a good way to do this is to inject the bean backing the new view into a bean backing the old view and have your "hit me!" action processor set the "test" property value in the new view backing bean.
An IDE is no substitute for an Intelligent Developer.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Changing Views with navigation handler in java and sending params to the changed view