开发者

Ajax support In h:selectOneMenu

开发者 https://www.devze.com 2023-03-02 19:17 出处:网络
I have to call backend code as soon as one value is selected from drop-down list. I am using JSF 2.0. In JSF 1.2 I did it 开发者_JAVA技巧by using <a4j:support> in <h:selectOneMenu>, but I

I have to call backend code as soon as one value is selected from drop-down list. I am using JSF 2.0. In JSF 1.2 I did it 开发者_JAVA技巧by using <a4j:support> in <h:selectOneMenu>, but I am not geting how to do it in JSF 2.0.


Use the <f:ajax> tag. It's much similar to the <a4j:support>.

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

with

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

The <f:ajax> has also an event attribute which already defaults to valueChange when used in <h:selectOneMenu>, so it is been omitted.

0

精彩评论

暂无评论...
验证码 换一张
取 消