I have a data table in which a detailed row select event dialog box will be displayed. However, the dialog box does not display the values โโof the selected object. I see that the selected object is correctly set during a debugging session.
The table consists of student rows, and it is assumed that you will see a pop-up dialog box with detailed information about the row selection event.
Student:
@Named(value = "studentBean") @SessionScoped public class StudentBean { @Inject private UserFacade userFacade; private List<User> studentList; private User selectedStudent; public StudentBean() { } @PostConstruct public void init() { studentList = userFacade.findAll(); } public List<User> getStudentList() { return studentList; } public void setStudentList(List<User> studentList) { this.studentList = studentList; } public User getSelectedStudent() { return selectedStudent; } public void setSelectedStudent(User student) { this.selectedStudent = student; } public void onRowSelect(SelectEvent event) { } public void onRowUnselect(UnselectEvent event) {
Facelet Page:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h ="http://java.sun.com/jsf/html" xmlns:p ="http://primefaces.org/ui"> <body> <ui:composition template="./layout.xhtml"> <ui:define name="content"> <h:form id="studentForm"> <p:dataTable var="student" value="#{studentBean.studentList}" selectionMode="single" selection="#{studentBean.selectedStudent}" rowKey="#{student.id}"> <p:ajax event="rowSelect" listener="#{studentBean.onRowSelect}" update=":studentForm:studentDetail" oncomplete="studentDialog.show()" global="true" immediate="true" /> <p:ajax event="rowUnselect" listener="#{studentBean.onRowUnselect}" /> <p:column headerText="First Name"> <h:outputText value="#{student.firstName}" /> </p:column> <p:column headerText="Last Name"> <h:outputText value="#{student.lastName}" /> </p:column> <p:column headerText="Student ID"> <h:outputText value="#{student.studentid}" /> </p:column> </p:dataTable> <p:dialog id="dialog" header="Student Detail" widgetVar="studentDialog" resizable="false" showEffect="fade" hideEffect="fade" appendToBody="true"> <h:panelGrid id="studentDetail" columns="2" cellpadding="4"> <h:outputText value="First Name: " /> <h:outputText value="#{studentBean.selectedStudent.firstName}" /> <h:outputText value="Last Name: " /> <h:outputText value="#{studentBean.selectedStudent.lastName}" /> </h:panelGrid> </p:dialog> </ui:define> </ui:composition> </body> </html>
I follow the example of a machine data table on the Presentations page. It seems so simple, but I canโt display the selected information about what I am doing. The dialog box displays fine, but the values โโof firstName and lastName are empty.
I tried the following:
- Inclusion of dialogue in another form
- Use process = "@form"
- Use process = ": studentForm: studentDetail"
What am I doing wrong?
Charts 3.3.1, Glassfish 3.1.2
source share