Hi
I have a listgrid displaying many records.
1. In my listgrid say i have 10 columns.
2. I have a java bean with these 10 attributes.
3. In my DAO class after querying the database i populate the resultset into arraylist of bean objects.
4. I pass that arraylist to my manager class and set it in dsResponse.setData() method.
5. Now on the screen all the records are displayed.
6. Now if i edit few cells in a record and click on save then i should update the database with edited values.
7. In my update method in manager class, i will get all the edited values record by record using newValues Map.
8. But the user can modify the cells in a record in any combination. Many combinations are possible. I can not generate the query dynamically to all the possible combinations. Its a tedious task.
9. Is there any way i get the values of all the cells(edited and non-edited) of a particular record in the bean, so that i can pass that bean object to my DAO class and then update the database. In this case i can write only one update query.
a simple example:
on the screen the record displayed for the columns A,B,C and D is
User edits few values(say 1 to 5 and 3 to 7) and before he clicks on save the listgrid looks like
Now when he clicks on save, in my update method of manager class i should have bean object with attribute values: a->5, b->2, c->7, d->4
so i will write a single update query
Update TableT set A=5, B=2, c=7, d=4 where ............
I thought i can achive this as mentioned below:
in update method get old values of a record from listgrid using dsRequest.getOldValues(); write some logic to populate the bean with a mix of old and new values and then send that bean object to DAO class.
If a listgrid has fewer columns then what i though might work out. Suppose if a listgrid has many columns(say >20) then i feel my approach is not the right one.
How i can achive this in a best possible way.
I have a listgrid displaying many records.
1. In my listgrid say i have 10 columns.
2. I have a java bean with these 10 attributes.
3. In my DAO class after querying the database i populate the resultset into arraylist of bean objects.
4. I pass that arraylist to my manager class and set it in dsResponse.setData() method.
5. Now on the screen all the records are displayed.
6. Now if i edit few cells in a record and click on save then i should update the database with edited values.
7. In my update method in manager class, i will get all the edited values record by record using newValues Map.
8. But the user can modify the cells in a record in any combination. Many combinations are possible. I can not generate the query dynamically to all the possible combinations. Its a tedious task.
9. Is there any way i get the values of all the cells(edited and non-edited) of a particular record in the bean, so that i can pass that bean object to my DAO class and then update the database. In this case i can write only one update query.
a simple example:
on the screen the record displayed for the columns A,B,C and D is
Code:
A B C D
------ ----- ----- -----
1 2 3 4
Code:
A B C D
------ ----- ----- -----
5 2 7 4
so i will write a single update query
Update TableT set A=5, B=2, c=7, d=4 where ............
I thought i can achive this as mentioned below:
in update method get old values of a record from listgrid using dsRequest.getOldValues(); write some logic to populate the bean with a mix of old and new values and then send that bean object to DAO class.
If a listgrid has fewer columns then what i though might work out. Suppose if a listgrid has many columns(say >20) then i feel my approach is not the right one.
How i can achive this in a best possible way.
Comment