• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multibox reset method ?

 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi good day to all ,
i have a multibox which i use to display it in datagrid to let user tick and delete specific records, as shown below :


here is my actionform


number of multiboxes will depend on the List, let take an example for the List contains 3 records, so end up we have 3 multiboxes here and the values are "0" for mltibox1 , "1" for multibox2 and "3" for multibox3 .

my problem is , when i tick the multibox1 which have value='0'and click on "Delete" Button which eventually delete the List element with index = 0 , and it return two list now , however, now the multibox with value="1" ticked as it become first row , can i know how to reset it and make it all unchecked ? i already make a reset method but seem doesn't work

thanks for guidance
[ September 14, 2006: Message edited by: Nakata kokuyo ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your ActionForm is in session scope, you will also have to reset the checkbox array to an empty array in the Action that performs the delete. Here is the sequence of events:

1- user checks a box and presses submit button

2- Struts calls reset, thereby making checkbox an empty array

3- Struts calls setCheckBox() making checkbox an array of at least one element.

4- The execute method of your Action class is called, performing the delete and forwarding back to the JSP.

5- JSP is redisplayed, and box still shows as checked because the checkbox array still has an element.

To fix this, you need to reset the array between steps 4 and 5.
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Merrill Higginson for enlighten, i tackled the problem by setCheckBox(new String[]{}) right after perform the deletion operation ,

my curious now, how struts actually work for setCheckbox() and getCheckbox()? what is the logic behind ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic