Conflict about required and valuechangeListener for <p:selectonemenu>

三世轮回 提交于 2019-12-13 04:46:05

问题


<p:selectOneMenu id="roleId" value="#{accessPage.roleId}" required="true">                   
   <f:selectItem itemLabel="#{msg['label.common.selecthere']}" itemValue="#{null}" />          
   <f:selectItems var="code" value="#{accessPage.roleIdList}" itemLabel="#{code.codeDesc}" itemValue="#{code.codeId}" />    
   <f:valueChangeListener type="com.ncs.caseconnect.base.app.utils.ValueChangeCleanUtils"/>    
   <p:ajax listener="#{accessPage.roleOrModuleChanged}" update="accessRight" />
</p:selectOneMenu>

the valueChangeListener and ajax not work when we select the first null option. If we remove the required attribute it works fine. Is it conflict between required and valueChangeListener?


回答1:


try to replace

<f:selectItem itemLabel="#{msg['label.common.selecthere']}" itemValue="#{null}" />  

with

<f:selectItem noSelectionOption="true" itemLabel="#{msg['label.common.selecthere']}"/>


来源:https://stackoverflow.com/questions/11027275/conflict-about-required-and-valuechangelistener-for-pselectonemenu

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