문제

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