<p:selectOneMenu> getting null on submit/next

[亡魂溺海] 提交于 2019-12-11 15:24:32

问题


I am using primefaces wizard. During wizard flow all parameters saved correctly . However <p:selectOneMenu> items getting NULL on submit.Also on 'back', it will not show what I have selected. Same for <p:selectManyMenu> also. Any solution ?

Here is the code snippets.I'm using primefaces-3.0.M3 and jsf2.

<h:outputText value="Employee Status" />
<p:selectOneMenu id="employeeStatus"value="#{employeeRepositoryImpl.employeeStatus.title}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Permanent" itemValue="Permanent" />
<f:selectItem itemLabel="Contract" itemValue="Contract" />
<f:selectItem itemLabel="Part-Time" itemValue="Part-Time" />
<f:selectItem itemLabel="Training" itemValue="Training" />
</p:selectOneMenu>
<p:message id="employeeStatusId" for="employeeStatus" />

This is in a <p:wizard> tab, while clicking next button or submit button, the itemValues getting null.Sorry for the re-post.


回答1:


Have you deleted the previous post?

Anyway, firstly, you should upgrade to Primefaces 3.0.M4!

Secondly, it would be better to use a list along with f:selectItems and all those String values to be stored in a list(this way you have more control over what's in the list and what should the list return), but if you want to stick with f:selectItem try using it with the enclosing tag (it may be a bug without it):

<f:selectItem itemLabel="Permanent" itemValue="Permanent" ></f:selectItem>

Also, I repeat myself, upgrade to Primefaces 3.0.M4!




回答2:


I have solved it by using primefaces AJAX

<p:ajax update="employeeStatus" listener="#{employeeRepositoryImpl.employeeStatusAjax}" />

inside my </p:selectOneMenu> and I check/process this in side employeeStatusAjax().



来源:https://stackoverflow.com/questions/8237555/pselectonemenu-getting-null-on-submit-next

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