我正在使用JSF 2.0和Primefaces 3.4.2
我有一个弹出式对话框,其中我有inputText
,selectOneMenu
,autoComplete
和<p:commandButton
我在selectOneMenu <p:ajax update="dept" listener="#{empMB.loadDepartments}" />
当我单击commandButton时,将调用selectOneMenu的listener和Converter类。 我没有调用commandButton的方法。这可能是什么原因?
JSF代码
<p:dialog header="My Panel" style="font-weight:bold"
widgetVar="NewDialog" resizable="false" id="NewDlg"
showEffect="fade" hideEffect="fade" appendToBody="true"
modal="true" position="center top" width="850" height="450">
<h:form id="createform">
<p:panelGrid columns="6">
<h:outputLabel value="Employee # " for="emp" />
<p:autoComplete value="#{mymb.selectedEmployee}"
id="emp" minQueryLength="3"
completeMethod="#{mymb.complete}"
var="p" itemLabel="#{p.employeeName}" itemValue="#{p.employeeNumber}"
forceSelection="true" >
<p:ajax event="itemSelect" listener="#{mymb.handleSelect}"
update ="empnumber phone />
<p:column>#{p.employeeName} - #{p.employeeNumber}</p:column>
</p:autoComplete>
<h:outputLabel value="Department" />
<p:inputText id="empnumber" value="#{mymb.employeeDetail.department}" >
</p:inputText>
<h:outputLabel value="Contact #" for="phone" />
<p:inputText id="phone" value="#{mymb.employeeDetail.phone}">
</p:inputText>
<h:outputLabel value="Employee Number" for="employeenumber" />
<p:inputText id="employeenumber" value="#{mymb.employeeDetail.employeeNumber}">
</p:inputText>
</p:panelGrid>
<p:separator />
<p:panelGrid columns="6">
<h:outputLabel value="Employees" for="employees" />
<h:selectOneMenu id="employees" value="#{empMB.employees}" converter="#{employeesConverter}">
<f:selectItems value="#{empMB.employeesItems}" var="cat"
itemLabel="#{cat.employeesName}" itemValue="#{cat.employeesCode}"/>
<p:ajax update="dept" listener="#{empMB.loadDepartments}" />
</h:selectOneMenu>
<h:outputLabel value="Dept employees" for="dept" />
<p:selectOneMenu id="dept" value="#{empMB.department}">
<f:selectItems value="#{empMB.departmentList}" var="dep"
itemLabel="#{dep.departmentName}"
itemValue="#{dep.departmentCode}" />
</p:selectOneMenu>
<p:commandButton value="Save" icon="ui-icon-check" style="margin:0"
actionListener="#{empMB.saveRequest}" />
</p:panelGrid>
<p:separator />
</h:form>
</p:dialog>
答案 0 :(得分:2)
当您处理整个表单(例如部门或其他部门)时,JSF可能无法设置某个字段。也许类型错了,或转换器失败。在表单中添加p:message
并在没有process="@this"
的情况下更新它,您可能会看到一些内容。