Paolo Pinkel wrote:I'm trying to put values in the requestScope from an action method.
Do you see anything wrong there?
Yes. You're creating a whole lot of clunky server-specific code to do what JSF was intended to do easily as one of its core functions.
JSF can define Request-scope beans in faces-config and then reference them as managed properties. The managed properties can be injected into other managed beans and/or referenced via EL expressions in View definitions. And you never have to get within 100 kilometers of FacesContext or any other javax.faces objects to do that.
You've made your job a little more difficult by making 2 request objects, each of which is a simple String-class object. Usually it's easier to define a custom class that holds both key and value with property accessor methods for each. You can then inject this object into a managed bean that initializes its key and value properties, which results in a view almost identical to the one you've coded except that instead of the name "requestScope", you'd substitute the name that your custom object was published under.
There is one "gotcha", however. You can't inject a request-scope object into a session-scope bean since the destination object's lifespan has to be shorter or equal than the injected object. This sometimes means that the "obvious" arrangement of objects has to be turned around.
One final warning. JSF uses postbacks that cause the same form to be sent and received multiple times. That doesn't work well with Request scope, since the Request scope objects get destroyed and created from scratch on each request. So Request scope is much less usable in JSF than it is in other J2EE frameworks.
An IDE is no substitute for an Intelligent Developer.
Joined: May 04, 2011
Thanks for this enlightening comment, Tim! I'm new to JSF, so... thank you! It's working now!