Ajax Support In h: selectOneMenu

I need to call the secondary code as soon as a single value is selected from the drop-down list. I am using JSF 2.0. In JSF 1.2, I did this using <a4j:support>in <h:selectOneMenu>, but I don't understand how to do it in JSF 2.0.

+3
source share
1 answer

Use the tag <f:ajax>. This is very similar to <a4j:support>.

<h:selectOneMenu value="#{bean.selectedItem}">
    <f:selectItems value="#{bean.selectItems}" />
    <f:ajax listener="#{bean.valueChanged}" />
</h:selectOneMenu>

with

public void valueChanged() {
    // ...
}

<f:ajax>also has an attribute eventthat defaults to valueChangewhen used in <h:selectOneMenu>, so it is not specified.

+10
source

All Articles