| Author |
Can JSF backup bean tell which View is using it?
|
Dheeman Basu
Greenhorn
Joined: Mar 17, 2009
Posts: 12
|
|
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.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14460
|
|
|
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.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Dheeman Basu
Greenhorn
Joined: Mar 17, 2009
Posts: 12
|
|
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?
|
 |
 |
|
|
subject: Can JSF backup bean tell which View is using it?
|
|
|