我在Primefaces6.0中面临模态(对话框)的问题。我有一个简单的数据表,有多种选择模式。 Datatable还有一个输入文本组件,在rowselect事件上,一个对话框填充显示有关该行的更多信息。这里的问题是当我第一次点击数据表行时,会出现一个对话框(这就是它应该如何工作)。现在关闭对话框并开始键入其各自的输入文本组件并点击空格键,出现对话框(这是实际的错误)。 此问题仅存在于Primefaces6.0中,并且相同的代码在Primefaces5.3 版本中正常运行。由于Primefaces6.0中可以对数据表和其他组件进行响应/调整大小,因此我必须坚持使用它,而不能使用另一个。请帮我解决我的问题。
代码示例如下: -
的index.xhtml
<p:dataTable id="dtEmployee" value="#{mbEmployee.lstEmployee}" var="emp" selection="#{mbEmployee.lstSelectedEmp}" rowKey="#{emp.regNo}">
<p:ajax event="rowSelect" update=":frmEmployee:diShow" oncomplete="PF('dgInfo').show();"/>
<p:column headerText="Employee No">
<h:outputText id="lblReNo" value="#{emp.regNo}"/>
</p:column>
<p:column headerText="Employee Name">
<h:outputText id="lblEmpName" value="#{emp.employeeName}"/>
</p:column>
<p:column headerText="Employee City">
<h:outputText id="lblCity" value="#{emp.city}"/>
</p:column>
<p:column headerText="Feedback">
<p:inputText id="txtFeedback" value="#{mbEmployee.feedback}"/>
</p:column>
<p:column headerText="Select" selectionMode="multiple" style="text-align: center"/>
</p:dataTable>
<p:dialog id="diShow" modal="true" widgetVar="dgInfo" closable="true">
<p:panelGrid columns="2">
<p:outputLabel id="DispRegNo" value="Reg No"/>
<p:outputLabel id="lblDispRegNo" value="#{mbEmployee.lstSelectedEmp[0].regNo} "/>
<p:outputLabel id="DispName" value="Employee Name"/>
<p:outputLabel id="lblDispName" value="#{mbEmployee.lstSelectedEmp[0].employeeName}"/>
<p:outputLabel id="DispCity" value="City"/>
<p:outputLabel id="lblDispCity" value="#{mbEmployee.lstSelectedEmp[0].city}"/>
</p:panelGrid>
</p:dialog>
java class:
@ManagedBean(name = "mbEmployee", eager = true)
public class employee {
private List<employeeBean> lstEmployee;
private List<employeeBean> lstSelectedEmp;
private String feedback;
public String getFeedback() {
return feedback;
}
public void setFeedback(String feedback) {
this.feedback = feedback;
}
public List<employeeBean> getLstEmployee() {
return lstEmployee;
}
public void setLstEmployee(List<employeeBean> lstEmployee) {
this.lstEmployee = lstEmployee;
}
public List<employeeBean> getLstSelectedEmp() {
return lstSelectedEmp;
}
public void setLstSelectedEmp(List<employeeBean> lstSelectedEmp) {
this.lstSelectedEmp = lstSelectedEmp;
}
public employee() {
lstEmployee = new ArrayList<>();
lstEmployee.add(new employeeBean("ABC", "XYZ", 45, 1001));
lstEmployee.add(new employeeBean("DEF", "XYZ", 45, 1002));
lstEmployee.add(new employeeBean("GHI", "XYZ", 45, 1003));
lstEmployee.add(new employeeBean("JKL", "XYZ", 45, 1004));
lstEmployee.add(new employeeBean("MNO", "XYZ", 45, 1005));
}
}
bean class:
public class employeeBean {
private String employeeName, city, feedback;
private int age, regNo;
public String getEmployeeName() {
return employeeName;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getFeedback() {
return feedback;
}
public void setFeedback(String feedback) {
this.feedback = feedback;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getRegNo() {
return regNo;
}
public void setRegNo(int regNo) {
this.regNo = regNo;
}
public employeeBean(String employeeName, String city, String feedback, int age, int regNo) {
this.employeeName = employeeName;
this.city = city;
this.feedback = feedback;
this.age = age;
this.regNo = regNo;
}
public employeeBean(String employeeName, String city, int age, int regNo) {
this.employeeName = employeeName;
this.city = city;
this.age = age;
this.regNo = regNo;
}
}
如果代码中存在任何错误或任何解决此问题的黑客行为,请告诉我。
答案 0 :(得分:0)