Datatable RowKey and Row Selection
Posted: 14 Sep 2018, 12:15
Hi,
I have this datatable which polulates correctly and selects the correct record on page load .... (this happens when a user selects a token on the previous screen)
Once the user has viewed the page they can return to the previous screen with
So this process works the first time
i.e user selects a token -> page loads up and the dataTable is polulated and selects the correct row
the second time a token is selected from the previous screen I get an error on the rowKey it throws a java.lang.IndexOutOfBoundsException because for some reason id1 is null
if I modify the code in the id1 getter to return a dummy key and bypass the null rowkey, the page loads up but the selection fails to occur
The odd thing is this happens every second attempt
i.e
1) select item 1 -> everything works -> leave screen
2) select item 1 -> get null key -> return dummy key -> selection fails -> leave screen
3) select item 1 -> everything works -> leave screen
4) select item 1 -> get null key -> return dummy key -> selection fails -> leave screen
I'm really at a loss , the issue does not seem to have anything to do with the item itself but when everything works the updateTokenView.primary getter
is called and when it fails then updateTokenView.primary is never called.
Anyone have any ideas - cleanup , form closing etc, why does a null ever appear on the rowkey, all my objects always have a rowkey - its like some dummy object is getting created at some point but from where?
Thanks!
Mike.
(PrimeFaces 6.2)
(JSF 2.2)
I have this datatable which polulates correctly and selects the correct record on page load .... (this happens when a user selects a token on the previous screen)
Code: Select all
<p:dataTable styleClass="s-alias-table" var="item"
value="#{updateTokenView.token.tokenXrefs}" rowIndexVar="index" selection="#{updateTokenView.primary}" rowKey="#{item.id1}">
<p:column headerText="Primary" id = "col" selectionMode="single" style="width:40px;text-align:center"/>
<p:ajax event="rowSelectRadio" listener="#{updateTokenView.onRowSelect}" />
<p:column headerText="Source">
<h:outputText value="#{item.srcSysCd}" />
</p:column>
</p:dataTable>
Once the user has viewed the page they can return to the previous screen with
Code: Select all
<p:commandButton value="Return to list" class="btnRegister" actionListener="#{mainView.displayLandingPage}" update="@(.s-page-body)" ajax="false" immediate="true" process="@none" />
So this process works the first time
i.e user selects a token -> page loads up and the dataTable is polulated and selects the correct row
the second time a token is selected from the previous screen I get an error on the rowKey it throws a java.lang.IndexOutOfBoundsException because for some reason id1 is null
if I modify the code in the id1 getter to return a dummy key and bypass the null rowkey, the page loads up but the selection fails to occur
The odd thing is this happens every second attempt
i.e
1) select item 1 -> everything works -> leave screen
2) select item 1 -> get null key -> return dummy key -> selection fails -> leave screen
3) select item 1 -> everything works -> leave screen
4) select item 1 -> get null key -> return dummy key -> selection fails -> leave screen
I'm really at a loss , the issue does not seem to have anything to do with the item itself but when everything works the updateTokenView.primary getter
is called and when it fails then updateTokenView.primary is never called.
Anyone have any ideas - cleanup , form closing etc, why does a null ever appear on the rowkey, all my objects always have a rowkey - its like some dummy object is getting created at some point but from where?
Thanks!
Mike.
(PrimeFaces 6.2)
(JSF 2.2)