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.

有帮助吗?

解决方案 2

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

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top