struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Barefoot" <>
Subject RE: *reset* why is it not being called
Date Fri, 25 Oct 2002 00:11:10 GMT
If you mean that you are using <input type="reset" ..> or <html:reset>, and this
is the button you are clicking, then there is no request being made to the server.  The reset
button is client-side;  the browser just resets the form to whatever the values were at the
time the form was last submitted.  That's why they "magically" return. :)

The reset() method in your ActionForm is *only* called when you do a submit to an action URL
that uses this ActionForm.  The reset *button* in html forms doesn't do a submit.  So, if
you want your reset() method to be invoked, you need another mini-form, which only contains
a submit button (you can label it reset, clear, or whatever) and maybe a hidden value or something
to instruct your action to not do anything (i.e., action=reset).  In your action, just check
for this value in the form or request, and do nothing.  The reset method in your form will
already have been called.

Note:  Do NOT use another submit button in the same html form as the one containing your entry
fields (use a separate form), as the values they contain will be submitted....and since Struts
calls the reset() method *before* populating your form, the form will still get populated
with the 'old' values, negating the effects of your reset logic.

hope this helps,

> -----Original Message-----
> From: Anthony Mutiso 2 []
> Sent: Thursday, October 24, 2002 4:34 PM
> To: ''
> Subject: *reset* why is it not being called
> I have a form that on succesful submission loops back to the 
> same page but
> more data is displayed at the bottom of the page. 
> My problem is that the reset button in the form only clears 
> the form to the
> data that was in the form after the last submit. So every 
> time I submit, if
> I press reset nothing appears to work. If clear the form 
> manually and press
> reset, my old values from my last submit magically return. 
> How to I correct this problem. config looks something like:
>    <action path="/search"
>            type="Test.SearchAction"
>            name="searchForm"
>            scope="request"
>            validate="true"
>            input="/search.jsp">
>       <set-property property="loginRequired" value="false"/>
>       <forward name="success" path="/search.jsp"/>
>       <forward name="failure" path="/search.jsp"/>
>    </action>
> and I have a "   <forward name="search" path="/"/>" 
> in my global
> forwards.
> My form is "<html:form action="/search" focus="value" >".
> and my reset function has clears my form, and has log 
> messages that I only
> see when the application start. Any pushing of the reset 
> button does not
> result in any new log entries.
> What gives?
> Thanks
> Anthony
> --
> To unsubscribe, e-mail:   
> <>
> For additional commands, e-mail: 
> <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message