jsfprimefacesuicomponents

How to get all rows of jsf or PrimeFaces datatable programmatically


I am using an datatable and every row has a selectonemenu as an column.

There is a button on my page.When it is clicked,i want to check every rows of datatable,find the selected item of selectone menu and make some database stuff depending on this selected value.

Is there a easier way without using programmatical way or any solution to my codes?

Here is my code:

Here I just tried to find a outputtext,but it did not work.

private DataTable myTable//primefaces datatable;



for ( UIComponent row : myTable.getChildren()) {
            HtmlOutputText  a=  (HtmlOutputText) row.findComponent("bname");

            System.out.println("click"+a.getValue());       

        }

Solution

  • Just bind selected values of selectionmen to a map.

    <p:dataTable .... rowIndexVar="index">
       ... somwhere in column
       <p:selectOneMenu value="#{backingBean.values[index]}" >
           ...