• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can JSF backup bean tell which View is using it?

 
Dheeman Basu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dheeman Basu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic