JSF selectOneMenu validation and ajax rendering -
i have validation on selectonemenu prevent user select "none" item in list.
<h:selectonemenu id="selectmenu" value="#{bean.selectedvalue}" required="true" requiredmessage="please select item"> <f:ajax render="torender selectmenumessage" listener="#{bean.onselect}"/> <f:selectitem itemlabel="none" noselectionoption="true"/> <f:selectitems value="#{bean.items}" var="item" itemvalue="#{item.id}" itemlabel="#{item.label}"/> </h:selectonemenu> i have panel below , want show when item not "none". when select "none", message should render , panel disappear.
<h:panelgroup id="torender"> <h:panelgrid rendered="#{bean.selectedvalue == 0 ? false : true"> ... </h:panelgrid> </h:panelgroup> it's working without validation can't make both work.. it's if validation prevents rendering.
any suggestion? thanks
i guess bean.selectedvalue integer, try this:
<f:selectitem itemvalue="0" itemlabel="none" noselectionoption="true"/> edit: ah sorry, think misunderstood problem little bit.
problem here is, if requiering value selectonemenu value not submitted if empty. , if item
noselectionoption="true" selected, handled empty, no value submitted. when checking against bean.selectedvalue == 0, selectedvalue never - except maybe - 0, because when select item value 0 not submitted, described above.right, validation , check
bean.selectedvalue == 0 can not work together. recommend remove validation.if no option you, please explain me why need work way in more details.
Comments
Post a Comment