Reputation: 6547
I got a strange (and probably) wrong behaviour here. I was trying to put a checkbox on the page, and you know it: unchecked checkboxes are not written to the request (only checked boxes are)
What struts normally offers is to override:
@Override
public void reset(ActionMapping mapping, ServletRequest request)
to reset all the checkboxes to "false". But in my case, this reset() is never called!
Someone got an idea?
Thanks in advance,
mana
Upvotes: 4
Views: 22164
Reputation: 64
I had a similar problem.
The solution was to add attribute scope="request" in the action tag in struts-config.xml
Upvotes: 2
Reputation: 1
prototype of reset()
method is:
public void reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
If we are not using reset()
method when that time we are trying to open our application then previous values will be coming automatically.
If we are using this reset()
method the previous values will be reset into empty values. So by using this reset()
method we can avoid previous values.
Upvotes: 0
Reputation: 51
The correct method signature to override is
public void reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
Upvotes: 4
Reputation:
The reset method is automatically called by the Struts framework (your observation on The Elite Gentleman's answer is correct)... that is if you did everything by the book.
Check the following:
name
attribute on the action
tag?My money is on number 4.
Upvotes: 2
Reputation: 89169
Reset is never called by default, you have to call it through your actions (if you want to reset your form),
alternatively, on your jsp, you'll have <html:reset />
tag and override the reset method of ActionForm
. this helps.
Upvotes: 0