ajax – 如何在selectOneMenu中将值传递给Listener
发布时间:2020-12-16 02:52:38 所属栏目:百科 来源:网络整理
导读:我有2个下拉菜单:Type码.如果值= A或B或C,我希望代码下拉列表根据类型下拉列表更改值.如何将A或B或C的值传递给侦听器,以便它可以理解和处理我的列表? h:outputLabel value="Type" for="idType" / h:selectOneMenu id="idType" value="#{myController.type}
我有2个下拉菜单:Type&码.如果值= A或B或C,我希望代码下拉列表根据类型下拉列表更改值.如何将A或B或C的值传递给侦听器,以便它可以理解和处理我的列表?
<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> 解决方法
从< f:ajax中删除event =“valueChange”或将其替换为event =“change” 您不必将值传递给已经存在的值(在changeCodeList方法中)
public void changeCodeList(AjaxBehaviorEvent ev) { System.out.println(type); //here is your value //now repopulate your list based on the value codeList = someMethod(type); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |