如何通过价值为听者selectOneMenu用于 [英] How to pass value into Listener in selectOneMenu
本文介绍了如何通过价值为听者selectOneMenu用于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个下拉列表:Type和放大器; code。我想code下拉到值取决于类型下拉列表,如果值= A或B或C.我如何可以通过A或B或C的值到侦听器,使其能够理解和处理我的名单变化?
< H:outputLabel值=类型为=idType/>
< H:selectOneMenu用于ID =idType值=#{myController.type}>
< F:选择信息itemLabel =AAAitemValue =AAA/>
< F:选择信息itemLabel =BBBitemValue =BBB/>
< F:选择信息itemLabel =CCCitemValue =CCC/>
< F:Ajax事件=valueChange监听器=#{myController.change codeLIST}渲染=ID code的执行=@这个/>
< / H:selectOneMenu用于>
< H:outputLabel值=code为=ID code/>
< H:selectOneMenu用于ID =ID code的价值=#{。myController的code}>
< F:选择信息itemLabel =选择...noSelectionOption =真/>
< F:selectItems的值=#{$ myController的C $ CLIST}/>
< / H:selectOneMenu用于>
解决方案
删除事件=valueChange
从< F:AJAX
或用替换事件=改变
您不必传递值作为已经存在(在变化codeLIST
法)
公共无效的变化codeLIST(AjaxBehaviorEvent EV){
的System.out.println(类型); //这里是你的价值
//现在重新填充基于值的列表
codeLIST =的someMethod(类型);
}
I have 2 dropdowns: Type & Code. I want the Code dropdown to change values depending on the Type dropdown if value = A or B or C. How can I pass value of A or B or C into listener so it can understand and process my List ?
<h:outputLabel value="Type" for="idType" />
<h:selectOneMenu id="idType" value="#{myController.type}">
<f:selectItem itemLabel="AAA" itemValue="AAA" />
<f:selectItem itemLabel="BBB" itemValue="BBB" />
<f:selectItem itemLabel="CCC" itemValue="CCC" />
<f:ajax event="valueChange" listener="#{myController.changeCodeList}" render="idCode" execute="@this" />
</h:selectOneMenu>
<h:outputLabel value="Code" for="idCode" />
<h:selectOneMenu id="idCode" value="#{myController.code}" >
<f:selectItem itemLabel="Select ..." noSelectionOption="true" />
<f:selectItems value="#{myController.codeList}" />
</h:selectOneMenu>
解决方案
remove the event="valueChange"
from your <f:ajax
or replace it with event="change"
You don't have to pass the value as its already there (in changeCodeList
method)
public void changeCodeList(AjaxBehaviorEvent ev) {
System.out.println(type); //here is your value
//now repopulate your list based on the value
codeList = someMethod(type);
}
这篇关于如何通过价值为听者selectOneMenu用于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文