Ajax support In h:selectOneMenu

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 09:49:44

问题


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 by using <a4j:support> in <h:selectOneMenu>, but I am not geting how to do it in JSF 2.0.


回答1:


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.



来源:https://stackoverflow.com/questions/5873711/ajax-support-in-hselectonemenu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!