• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get the action value from a commandButton in a managed bean

 
Tony David
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I have this simple button on a page B and I want to manage a navigation back on a page A.
This page B is linked to a managed bean "beanB" with a request scope.

So, when I click on this button, JSF will instantiate the the beanB due to the request scope.
In this constructor, I have several process, but for this navigation back I want to skip them
and trigger the navigation.

To do that I need a way to detect whether action value is "return". I tried many things
but without succes.

A solution would be to put a <f:param name="action" value="return"> inside my commandButton
and get it from the request object but I think it's a bit redundant, detect the action value would be simpler and
produces less code lines.

Thanks for your help.
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Tony!

The request scope beanB object won't exist for page A unless the page A View definition has EL that uses it. And it won't be the same beanB as page B used, since by definition, request-scope objects are created (instantiated) and destroyed on each request. A consequence, in fact, of using request scope is that you will have to run the extra instantiation code, since otherwise, the current copy of that bean won't have initialized properly.


 
Tony David
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your welcoming,

I can indeed, put my bean in session or view scope to avoid the constructor, but it's a simple page
so I think there is no need to clutter the session with such a bean, I would prefer detecting a navigation case
That's why I want to get the action value on server side.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!