I have a datatable listing a bunch of tests. I would like to show a Primefaces dialog after a user selects a row. The dialog references the data in the selected row, like "#{bean.selectedTest.name}". However, when the page is first rendered, there is no row selected and the references to the selected data yield "Target Unreachable, 'selectedTest' returned null" (the dialog references selectedTest.name).
I don't believe this is addressed in Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable which is otherwise awesome.
In the Primefaces Showcase for DataTable selection this is dealt with by using a FacesMessage, which is constructed AFTER the row is selected, rather than a dialog which exists in the page before. In my case I need user interaction in a dialog.
I have tried putting the dialog in a separate form as suggested in primefaces datatable selection issue, same problem.
I have tried to render the component inside the dialog that contains the references only after selectedTest is populated (rendered="#{not empty bean.selectedTest}"), and to both process and update the dialog after row selection, and this gets rid of the error, but the re-render never happens and the dialog pops up empty. I can see in my debugger that getSelectedTest() is called before setSelectedTest() and returns null. Is there some better way to force the re-render that I am missing? Or is this the wrong way to handle the problem?
I have worked around this by setting an arbitrary test to selected but this seems an ugly hack, since the row shows as selected but user hasn't actually selected anything.
Thanks in advance for help.