我正在使用 JSF 2.0 和 Primefaces 3.4.2
我有一个弹出对话框,其中很少有inputText
,和selectOneMenu
autoComplete
<p:commandButton
我在 selectOneMenu 中有以下内容<p:ajax update="dept" listener="#{empMB.loadDepartments}" />
当我单击 commandButton 时,将调用 selectOneMenu 的侦听器和 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>