scrollableDataTable onRowClick gets data from the second cli
j-pro Oct 12, 2007 9:43 AMGood afternoon!
Have noticed that I can get selected row data only after 2nd and next clicks. I'll explain. I have:
<h:form id="staffDataTable_Form">
<rich:scrollableDataTable height="200px" rowKeyVar="rkv" frozenColCount="1"
binding="#{staffSDTableMan.sdTable}" selection="#{staffSDTableMan.scrollableDataTableSelection}"
rowClasses="sdt_row1,sdt_row2" selectedClass="sdt_row_selected" activeClass="sdt_row_active"
width="470px" id="staffDataTable" rows="#{amBean.employeeListMan.listSize}" columnClasses="sdt_col"
value="#{amBean.employeeListMan.staffEmployees}" var="employee" sortMode="single">
<a4j:support event="onRowClick" onSubmit="this.style.backgroundColor='#000000" actionListener="#{staffSDTableMan.sdtRowSelected}"/>
<rich:column id="firstName">
<f:facet name="header"><h:outputText styleClass="sdt_head" value="First Name" /></f:facet>
<h:outputText value="#{employee.firstName}" />
</rich:column>
<rich:column id="lastName">
<f:facet name="header"><h:outputText styleClass="sdt_head" value="Last Name" /></f:facet>
<h:outputText value="#{employee.lastName}" />
</rich:column>
<rich:column id="sex">
<f:facet name="header"><h:outputText styleClass="sdt_head" value="Sex" /></f:facet>
<h:outputText value="#{employee.sex}" />
</rich:column>
<rich:column id="birthDate">
<f:facet name="header"><h:outputText styleClass="sdt_head" value="Birth Date" /></f:facet>
<h:outputText value="#{employee.birthDate}" />
</rich:column>
<rich:column id="birthPlace">
<f:facet name="header"><h:outputText styleClass="sdt_head" value="Birth Place" /></f:facet>
<h:outputText value="#{employee.birthPlace}" />
</rich:column>
</rich:scrollableDataTable>
<BR style="text-size:3px;"/>
<a4j:commandButton action="#{staffSDTableMan.prepareNewWorker}" value="Make prikaz"></a4j:commandButton>
<a href="javascript:Richfaces.showModalPanel('editWorker_panel',{width:700, top:200})">Edit</a>
</h:form>And here is my sdtRowSelected method:
public void sdtRowSelected(ActionEvent event)
{
System.out.println("==============>>>>>>>>>>>>>>>>>>>>>> rowSelected");
Iterator keys = this.scrollableDataTableSelection.getKeys();
while(keys.hasNext())
{
System.out.println("hasNext!");
Object key = keys.next();
}
System.out.println("Finished!");
}When I redeploy my application, and run it for the first time, my first click gives such log:
16:26:32,970 INFO [STDOUT] ==============>>>>>>>>>>>>>>>>>>>>>> rowSelected 16:26:32,970 INFO [STDOUT] Finished!
and the second, and other next clicks(even after Ctrl+F5) give:
16:26:48,205 INFO [STDOUT] ==============>>>>>>>>>>>>>>>>>>>>>> rowSelected 16:26:48,205 INFO [STDOUT] hasNext! 16:26:48,205 INFO [STDOUT] Finished!
I wonder why does it happen? Do I do something wrong, or it's some kind of a bug?
P.S.: I've also tried the way I make it with simple dataTable, like this:
Integer currIndex = getSdTable().getRowIndex(); List allData = (List) getSdTable().getValue(); Object rowData = new Object(); rowData = allData.get(currIndex);
but currIndex was always -1. That's why I've decided to make as above, but I'm surprised with that second click...
Thanks for your answer in advance.