Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling action method from t:selectOneMenu

 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, my requirement is to call an action method and take the user to the next screen as soon as he selects one item from the drop down. Can anyone suggest how to map action method to t:selectOneMenu.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Javascript to submit the form on change of the dropdown. Make the action method the default UICommand action of the form (the firstnext h:commandButton of the form).
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shasi Mitra wrote:Hi, my requirement is to call an action method and take the user to the next screen as soon as he selects one item from the drop down. Can anyone suggest how to map action method to t:selectOneMenu.


The a4j tag library from the JBoss Richfaces project is useful for that. Here's an example:



This example isn't calling an action method, it's setting the "setLocation.city" property immediately. To fire an action, add the "action=" attribute to the a4j:support element just like you would for a commandButton.

The nice thing about this is that you don't have to write any Javacript to get the benefits of AJAX. Also, by selecting elements using the reRender attribute, you can update parts of the page without having to refresh the entire page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic