Question

I'm using the Display tag library with struts 1.3

I would to display data in such a way that the user can change the value in the last column (that is the last column is editable).

I've found this, but I wouldn't use checkboxes.

I would example well explained, if it's possible, to how achieve this goal.

Have I to use decorators? How can I know what rows the user has edited?

Was it helpful?

Solution

I did this sort of manually. It might help.

Give that editable column a name and put a text box in the column.

<table>
    <tr><td><input type="text" name="editable"/></td</td>
    <tr><td><input type="text" name="editable"/></td</td>
    <tr><td><input type="text" name="editable"/></td</td>
</table>

when you submit the form and do httpRequest.getParameter("editable") in your servlet, you should get an array/list of values in text boxes in the order it is displayed.

You then could do the previous search that was done to display the data and compare it with the above list.

String[] editedList = httpRequest.getParameter("editable");
Object[] originalList = dao.getList(...);

List<Object> editedItems = new arrayList<Object>();

for(int i=0; i < originalList; i++){
    if(editedList[i].equalsoriginalList[0].getProp()){
        //No changes have been made
    }else{
        //Changes have been made.
        editedItems.add(originalList[i]);
    }
}

With this you'll end up with list of edited objects editedItems

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top