开发者

Ajax support In h:selectOneMenu

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜