• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Calling action method from t:selectOneMenu

 
Ranch Hand
Posts: 101
Spring Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Saloon Keeper
Posts: 28319
210
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

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.
 
Does this tiny ad smell okay to you?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic