• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get the action value from a commandButton in a managed bean

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic