How can I get values out of a selectOneMenu inside a JSF datatable?

前端 未结 2 396
臣服心动
臣服心动 2021-01-19 10:57

I have a JSF datatable with a bunch of rows, with each row having a selectOneMenu inside of it like this:

    

        
2条回答
  •  北海茫月
    2021-01-19 11:38

    I see your table has binding to your bean. In your bean you can use the getDataTable() method and access it. Java doc says:

    public Object getRowData()
    
    Return the data object representing the data for the currently selected row index, if any.
    

    So if you do your code like:

    List selectedRowData = (List) getDataTable().getRowData()
    

    You can then access all the fields the user has chosen. Im using this in my own project and its working. The only difference is that Im casting to my own type instead of List

提交回复
热议问题