I want to share a request scoped JSF bean in more than one view with h:inputText X and Y that will bind with member variables mX and mY.
But on Submit the bean should be intelligently invoke different processes. Say I have two views V1 and V2. One solution would be to define two funtions in JSF bean submitV1() and submitV2() and bind them
<h:commandButton id="submit" action="submitV1"> </h:commandButton> in V1 and similar expression in V2
But that would mean for every new view I have to write a new submit function. Can I define something like hidden input text that will set a hidden member variable mV to "V1" or "V2" implicitly without knowlege of user? The JSF bean then can intelligently decide how to handle the Submit. Basically, I need the JSF backup bean to figure which View is calling it.
You can instantiate a request-scope object with a property bound to an inputHidden object in the JSF View. It's perfectly OK to reference more than one backing bean on a view, even in different scopes.
An IDE is no substitute for an Intelligent Developer.
Joined: Mar 17, 2009
Thanks Tim. This is exactly my line of thought. I must use somehow <h:inputhidden?> tag. But I cannot figure the syntax.
Let's say the request scoped backing bean name is MyBean.
The property name is String formName
In view V1 I want formName to get set to "V1".
How do I write <h:inputhidden ................ /> block?