struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard Miller" ...@howardmiller.co.uk>
Subject Re: When *exactly* does reset get called?
Date Sat, 12 Oct 2002 20:20:25 GMT
Got it!!  I hadn't thought clearly enough about what was happening.

Thanks everybody.


On 12 Oct 2002 at 10:25, David M. Karr wrote:

> >>>>> "Antoni" == Antoni Reus <antoni.reus@wanadoo.es> writes:
> 
>     Antoni> Hi,
>     Antoni> A Dissabte 12 Octubre 2002 14:08, Howard Miller va escriure:
>     >> Hi,
>     >> 
>     >> Can soebody explain when the reset method of ActionForm gets called?
>     >> 
>     >> My problem is that I am using the method to prepopulate the form (which
>     >> works). The previous jsp had a link to the following jsp (the jsp not its
>     >> action - .jsp not .do, ok). The reset obviously runs and the preloaded
>     >> values appear.
>     >> 
>     >> When I submit the form, the reset method appears to get called again, so
I
>     >> lose my user entered values. Not wat I expected. And yes the <html.form>
>     >> tag does point to the .do action.
> 
>     Antoni> The reset method is called on every request that uses the form, before

>     Antoni> populating it with the parameters in the current request, and calling
the 
>     Antoni> action.
> 
>     Antoni> You can do a "selective" reset with something like this
> 
>     Antoni> public void reset ( mapping, request) {
> 
>     Antoni> 	if (!mapping.getPath().equals( "whatever"))  {
>     Antoni> 		// do the reset
>     Antoni> 	} 
>     Antoni> }
> 
> From the original description, it sounds like your "reset" method is using
> business logic to get data values to populate your fields with.
> 
> From Antoni's explanation of how "reset" is used, I hope it's clear that won't
> work very well.
> 
> The ActionForm.reset() method should only be used to CLEAR form values, before
> they are populated from the request.  You should use business logic in your
> Action class to populate form beans.
> 
> -- 
> ===================================================================
> David M. Karr          ; Java/J2EE/XML/Unix/C++
> dmkarr@earthlink.net
> 
> 
> --
> 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