Question

I need to intercept valueChange event on h:SelectOneMenu element, but it does not work. What I could miss?

I tried both this:

<h:selectOneMenu value="#{MainPage.<value_name>}"
                         valueChangeListener="#{MainPage.<method_name>}">
...
</h:selectOneMenu>

and this:

<h:selectOneMenu value="#{MainPage.<value_name>}">
...
    <f:ajax render="@form" event="change" listener="#{MainPage.<method_name>}"/>
</h:selectOneMenu>

these do not want to work.
Here is my method:

public void <method_name>(ValueChangeEvent e){
    ...
    System.out.println(">>>Changed<<<");
}

as a result, nothing happened, and there are no any errors in logs.
I'm using NetBeans 7.3 with jboss AS 7.1.

Was it helpful?

Solution 2

<h:message/> tag helped me to deal with my problem. The problem was in types and in lack of custom converters.

OTHER TIPS

For the first way, try to add the essential attribute :

<h:selectOneMenu onchange="submit()" ... >

For the second way, the class of the paramter event in the method should be : AjaxBehaviorEvent.

Also, make sure your controller-bean is @ViewScoped.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top