• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Multibox reset method ?

 
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic