aspose file tools*
The moose likes JSF and the fly likes Can JSF backup bean tell which View is using it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Can JSF backup bean tell which View is using it?" Watch "Can JSF backup bean tell which View is using it?" New topic
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: 16141
    
  21

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can JSF backup bean tell which View is using it?