File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Calling action method from t:selectOneMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Calling action method from t:selectOneMenu" Watch "Calling action method from t:selectOneMenu" New topic
Author

Calling action method from t:selectOneMenu

Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

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

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Jun 25, 2001
Posts: 16065
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Calling action method from t:selectOneMenu