0

I'm trying to get selected row index from dataTable to my bean. Tried tons of things, none of them worked.

Here's my dataTable:

        <p:dataTable rowIndexVar="k" var="item" value="#{configBean.configTable[0]}"  selectionMode="single"  selection="#{config.selectedList}" rowKey="#{item}">
            <p:column headerText="1">
                #{config.configTable[0][k]}
            </p:column>
            <p:column headerText="2">
                #{config.configTable[1][k]}
            </p:column >
            <p:column headerText="3">
                #{config.configTable[2][k]}
            </p:column>
            <p:column headerText="4">
                #{config.configTable[3][k]}
            </p:column>
            <p:column headerText="5">
                #{config.configTable[4][k]}
            </p:column>
            <p:column headerText="6">
                #{config.configTable[5][k]}
            </p:column>
            <p:column headerText="7">
                #{config.configTable[6][k]}
            </p:column>
            <p:column headerText="8">
                #{config.configTable[7][k]}
            </p:column>
            <p:column headerText="9">
                #{config.configTable[8][k]}
            </p:column>
            <p:column headerText="10">
                <p:commandButton value="Konfiguracja" actionListener="#{configBean.getIndex()}"/>
            </p:column>
    </p:dataTable>

I've tried putting Lists, strings and ints to "selection" to get some data from it, with no luck.

configTable is List<List<String>>=ArrayList<>();

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
ceroeps
  • 61
  • 1
  • 5
  • Why do you need to pass the index when you can pass the object? If you need the index, you can retrieve it IN the actionListener (if the bean scope is long enough) And you also have the 'rowIndexVar'... – Kukeltje Aug 31 '15 at 09:57
  • but, how to pass the object if its String? – ceroeps Aug 31 '15 at 10:07
  • String is an Object... See the duplicate Q for all possible solutions – Kukeltje Aug 31 '15 at 10:15

0 Answers0