struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Affan Qureshi" <quere...@etilize.com>
Subject Re: *reset* why is it not being called
Date Fri, 25 Oct 2002 06:57:04 GMT
I think you should use JavaScript function for your req. and change teh tye
of the "Reset" button to BUTTON and call a JS function on its click().

----- Original Message -----
From: "Joe Barefoot" <Joe.Barefoot@motiva.com>
To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
Sent: Thursday, October 24, 2002 5:11 PM
Subject: RE: *reset* why is it not being called


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,
Joe

> -----Original Message-----
> From: Anthony Mutiso 2 [mailto:anm1@utilitynet.net]
> Sent: Thursday, October 24, 2002 4:34 PM
> To: 'struts-user@jakarta.apache.org'
> 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="/search.do"/>"
> 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:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
>
>

--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message