Hello experts, I have very strange problem in ADF table with multiple selection mode. First time when I select a record and hit command button to process the selected request, rowSetIterator.getRow(key) is throwing null pointer exception. Second time when click on any record and hit command button again , rowSetIterator.getRow(key) does not throw error rather it gives me the record. Here is my code :
<af:table value="#{bindings.paymentList.collectionModel}" var="row"
rows="#{bindings.paymentList.rangeSize}"
emptyText="#{bindings.paymentList.viewable ? 'No requests found.' : 'Access Denied.'}"
columnStretching="column:c8" width="860px;"
fetchSize="#{bindings.paymentList.rangeSize}"
disableColumnReordering="true" rowBandingInterval="1"
inlineStyle="height:400px;"
filterModel="#{bindings.paymentListQuery.queryDescriptor}"
queryListener="#{bindings.paymentListQuery.processQuery}"
filterVisible="true" varStatus="vs"
selectionListener="#{viewScope.myBean.currentSelectionListener}"
rowSelection="multiple"
id="t1"
binding="#{viewScope.myBean.myTable}">
<af:column .....>
.....
</af:table>
<af:commandButton text="ProcessRequest"
id="cbProcReq"
binding="#{viewScope.myBean.processReqCB}"
action="#{viewScope.myBean.processRequests}" >
</af:commandButton>
currentSelectionListener() :
rksSelectedRows = searchResultTable.getSelectedRowKeys();
if (rksSelectedRows != null && !rksSelectedRows.isEmpty()) {
System.out.println("rksSelectedRows is not null or empty"); // always gets executed
}
}
processRequests():
RowKeySet rksSelectedRows = myTable.getSelectedRowKeys();
if(null != rksSelectedRows && !rksSelectedRows.isEmpty()){
Iterator itrSelectedRows = rksSelectedRows.iterator();
RowSetIterator rowSetIterator = dcItteratorBindings.getRowSetIterator();
while (itrSelectedRows.hasNext()) {
Key key = (Key)((List)itrSelectedRows.next()).get(0);
if( null !=rowSetIterator.getRow(key)) { //works only 2nd time click. First time click is throwing null for getRow()
PaymentReq paymentReq =(PaymentReq)((DCDataRow)rowSetIterator.getRow(key)).getDataProvider();
reqList.add(paymentReq);
}else {
System.out.println(" getRow() is null");
}
}
I noticed that key never becomes null. Something is getting populated always. No idea why this glitch. Why always 2nd time click is working ?
I also checked that Row myRow = rsiSelectedRows.getRow(key); is showing myRow as null for the first time. But 2nd time when I click and hit button, myRow is not null !! Do not know what is this glitch.
Appreciate your help.
thanks