将问题更新到以下内容:
请参阅附件代码。
<h:form id="tblForm" styleClass="formTblClass">
<h3 style="text-align: center; background-color: purple; color: white;">Contact Details</h3>
<h:panelGrid id="contactPanel" columns="3">
<h:outputLabel for="roleIn" value="Role: " />
<h:selectOneMenu id="roleIn" value="#{docHeader.roleIn}" required="true" requiredMessage="Please select one from dropdown.">
<f:selectItem itemLabel="--Select--" noSelectionOption="true"/>
<f:selectItems value="#{docHeader.listOfRoles}"/>
</h:selectOneMenu>
<h:message for="roleIn" style="color: red;"/>
<h:outputLabel for="empIdIn" value="Employee ID: " />
<h:inputText id="empIdIn" value="#{docHeader.empId}" required="true" requiredMessage="Please enter valid employee id">
<f:ajax listener="#{docHeader.fetchEmpDetails}" render="empName workPhone emailId" />
</h:inputText>
<h:message for="empIdIn" style="color: red;"/>
<h:outputLabel for="empName" value="Name: " />
<h:inputText id="empName" readonly="true" value="#{docHeader.empName}" /><br/>
<h:outputLabel for="workPhone" value="Work Phone: " />
<h:inputText id="workPhone" readonly="true" value="#{docHeader.workPhone}" /><br/>
<h:outputLabel for="emailId" value="Email ID: " />
<h:inputText id="emailId" readonly="true" value="#{docHeader.emailId}" /><br/>
</h:panelGrid>
<h:commandButton value="Add">
<f:ajax event="click" listener="#{docHeader.addContactToList}"
render="contactPanel contactTable" execute="@this contactPanel" />
</h:commandButton>
<h:dataTable id="contactTable" value="#{docHeader.contactList}"
var="contact" headerClass="list-header" rowClasses="list-row" columnClasses="list-column-center" border="1" width="100%">
<h:column>
<f:facet name="header">Role</f:facet>#{contact.roleIn}
</h:column>
<h:column>
<f:facet name="header">Employee ID</f:facet>#{contact.empId}
</h:column>
<h:column>
<f:facet name="header">Employee Name</f:facet>#{contact.empName}
</h:column>
<h:column>
<f:facet name="header">Work Phone</f:facet>#{contact.workPhone}
</h:column>
<h:column>
<f:facet name="header">Email ID</f:facet>#{contact.emailId}
</h:column>
</h:dataTable>
<div style="text-align: center">
<h:commandButton value="Next">
<f:ajax event="click" render="none" listener=""/>
</h:commandButton>
</div>
</h:form>
从上面的代码中,addtoContactList 工作得很好,contactTable 也显示了信息。
但是,当单击“下一步”时,我会收到必填字段消息,并且无法导航到下一页。
单击下一步时,我想在托管 bean 中执行一个方法,例如 moveToNextPage。
任何想法表示赞赏。