If you are reading this post, you are probably having a dataTable that does Row selection either using checkbox, Radio button or non of these but selectable, but if you just want to know how to achieve Row selection, then click here. You wish to display something on the same page based on the selected row, you have tried but it seems not to work. It seems to work for a dialog but not for other sections of the page that are not in the dialog. I suffered for about three days trying out different things, but on the 4th day I got it right. So here it is....
When you have a dataTable with row selection, there are 3 scenarios;
- You have checkboxes : multiple Selection
- You have Radio Buttons: Single Selection
- You neither have Checkboxes nor Radio buttons, but your Rows are selectable.
If you are using scenario 1 or 2 (If you must have checkboxes, or Radio buttons), refer to this page.
If you want to update another section of the page, there are two scenarios;
- The section you wish to update is in the same form with the dataTable and on the same page
- The section you wish to update is in another form and on the same page. If you are using this option, you just need to know how to call the id of the component e.g :form:Container:idOfComponent
<p:dataTable>
<p:event="rowSelect" update="Id of component you wish to update" listener="a method that you wish to execute when you select a row"
</p:dataTable
If you want a more descriptive example, look at this
The reason why I had to suffer for 3 days was, I didn't know that I had to use scenario 3 for things to work. This was all I had to find out.