• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

html:multibox problem

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is html:multibox placed on my form for status. Problem is, when I select any values from multibox and submit the form, second time when submit the form by deselecting previous values, previous values of boxes are checked.
Can anybody tell me what might be the reason?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason is that nothing is submitted to the server when a checkbox is unchecked. For this reaason you should override the reset(...) method of ActionForm to set the String array associated with the checkboxes to an empty array (new String[0]). Struts calls reset before populating the properties, so only when boxes are checked will there be a value in the array. Otherwise it will be empty.
 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply Merrill.
But I have another problem regarding this.
I have 2 jsps, one is to display criterias that user can apply and second is the result page.
On this result page there are Back and Refresh buttons.
On clicking Back button, it should go to first page and
On clicking Refresh button, it should refresh result page with previous form criterias.
Previously I used to call that action again on click of Back & Refresh button.
If I add this reset(..) method, form criterias are got reset, and on refresh it gives me NullPointerException.
Is there any way to tackle this?

Thanks
Deepa
[ April 24, 2007: Message edited by: Deepa More ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Overriding reset(...) alone would not have caused a NPE. Please show use the contents of your reset method, as well as the full text of the error message along with the first few lines of the stack trace. Also, are you overriding the function of the back button? If so, show us specifically what you're doing.
 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That NPE was because of some mistake, but the problem is form getting reset on Back and refresh.

(I wrote onClickf as it was not able to save it with correct one)

And these are javascript functions:


And in action class, for first time and for Back option, we are setting forward as first page and for others we call DAO to get values from database.
Now if I write reset(...) method in form, as you said every time form is submitted it calls this method, so form values get reset.
So my Back & Refresh buttons doesn't work as they should be.
Back button does not go to previous history page, it should go to first criteria page, so we call submit on that too.

Hope you got my problem.

[ April 25, 2007: Message edited by: Deepa More ]

[ April 25, 2007: Message edited by: Deepa More ]
[ April 25, 2007: Message edited by: Deepa More ]
 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried overloading reset() method with no args and calling that method for first time only, then back/refresh works fine, but multi box problem remains.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't reset everything in your reset method. Just reset the array used as the property for the html:multibox tag.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to UP this topic, but it was really useful to me.

Thanks Merrill
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic