Onchange isn't an action, so you can't use an Action method for a change in a dropdown. However, you can use a ValueChangeListener.
Aside from the difference in what method you define, there's also a difference in what it's safe to do in a ValueChangeListener, since the phase that actually sets the updated properties in the backing bean hasn't been done yet. And if you want to sleep well at night, you won't try to update the properties yourself in the ValueChangeListener method.
Bjoke: A "Bully Joke". A Statement or action made with malicious intent - unless challenged. At which point it magically transforms into "I was just funnin'" or "What's the matter, can't take a joke?"
There is a tricky approach to realize your request.
1. Set the 'onchange' attribute of <h:selectOneMenu> to 'submit()'.
2. In the corresponding valueChangeListener method, invoke the action method you want to use and invoke renderResponse method. Like following:
The principle as following:
Once the selection changed, a submission will be performed. The valueChangeListener method will be invoked first. Then you can freely invoke your action as any simple, normal methods. At last invoking renderResponse method will let system directly render the response to browser, jumping over the following normal JSF phases. In the other word, other actions or actionListeners will not process any more.
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop