szczecin
asked on
Datatable row index problem
I have a problem with Sun's JSF datatable component. If two persons are working on the same page containing h:datatable component and one of them make the action, that change contents of the table (for example removes one row), second (without refreshing!) when clicks on the specific row, gets the index of different one!
It hasn't happened when I run my web app on Tomcat 5. Now I use 6 (JBoss Web 2.0.1) and I have the same problem on each page containing datatable...
Obviously myDataTable.getRowIndex() is used in backend to identify row. And it's enumerated from 0, incremented by 1. So if I have table like this:
0 A
1 B
2 C
3 D
I load page in two windows, in one I delete row with index 1 (B). Now in second (not refreshed) I want to delete index 2 (C). As a result, D will be deleted as after first delete it has index 2 now...
I hope I explained good enough. I load the table, meanwhile someone update it, I don't know about it and I delete wrong row because indexation has changed...
It hasn't happened when I run my web app on Tomcat 5. Now I use 6 (JBoss Web 2.0.1) and I have the same problem on each page containing datatable...
Obviously myDataTable.getRowIndex() is used in backend to identify row. And it's enumerated from 0, incremented by 1. So if I have table like this:
0 A
1 B
2 C
3 D
I load page in two windows, in one I delete row with index 1 (B). Now in second (not refreshed) I want to delete index 2 (C). As a result, D will be deleted as after first delete it has index 2 now...
I hope I explained good enough. I load the table, meanwhile someone update it, I don't know about it and I delete wrong row because indexation has changed...
<h:dataTable binding="#{page1.myDataTable}" headerClass="list-header" id="myDataTable" rowClasses="list-row-even,list-row-odd" rows="#{page1.tableRowsNo}"
value="#{page1.myTableValue}" var="currentRow" width="99%">
[...]
<a4j:commandButton id="button_first" immediate="true"
onclick="submitActiont('#{page1.myDataTable.rowIndex}'')" style="width: 50px"
styleClass="Btn2" value="Edit"/>
</h:datatable>
public String editButton_action() {
Integer requestId =
((model.myTableDataModel)myDataTable.getRowData()).getMyId();
// getting this:
// myDataTable.getRowIndex();
// is the problem
[...]
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Integer requestId = ((model.myTableDataModel)m
So get the object by yourID, not by table row index.