问题
<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