struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Crossley <jcross...@ifleet.com>
Subject Re: Re[4]: proper/best way to create a "true" reset after some validation comes back
Date Fri, 12 Apr 2002 16:24:07 GMT
Hmm.  That smells like the behavior of the browser's reset button
(what you get with <html:reset/>).  Are you *sure* the correct
javascript function is getting called?  If you are, then I'm at a loss
for what could be wrong.  In the immortal words of every asshole
developer out there, "It works for me."  :-)

Rick Reumann <maillist@reumann.net> writes:

> Still not working here, although not totally sure why. The javascript
> works fine for resetting the fields the first time the jsp comes up,
> but after it is submitted with some errors and the validation errors
> come back, calling this reset function is not clearing all the fields.
> It is only clearing fields that are newly typed. Any more insight to
> why this would be happening?
> 
> On Friday, April 12, 2002, 10:59:44 AM, Jim wrote:
> 
> JC> I don't think so, Rick.  The javascript effectively mimics a user
> JC> manually clearing out all the fields on the form.  Once the form
> JC> is submitted, the new values (empty unless the user put something
> JC> in after invoking resetForm) will populate the formbean prior to
> JC> invoking validate.  Upon failing validation, those same values
> JC> will be presented to the user with the error message, if any.
> 
> JC> Try it and see.
> 
> JC> -- Jim
> 
> JC> Rick Reumann <maillist@reumann.net> writes:
> 
> >> The problem (from what I can gather) using this javascript approach is
> >> that it really isn't clearing out what is in memory. So for example
> >> say you call this function and the form clears out but the user types
> >> in something in the wrong format, when he now submits and gets back
> >> the validation errors it will also include stuff filled in the form
> >> that was there before this javascript function was called. I'm pretty
> >> sure this is what would happen but I could be wrong.
> >> 
> >> On Friday, April 12, 2002, 10:09:35 AM, Jim wrote:
> >> 
> >> JC> Gross, but effective:
> >> 
> >> JC> <script language="JavaScript">
> >> JC>     <!--
> >> JC>     function resetForm()
> >> JC>     {
> >> JC>       var f = document.forms[0]
> >> JC>       for (var i=0; i<f.length; ++i) {
> >> JC>         if (f.elements[i].type != "hidden") {
> >> JC>           f.elements[i].value = '';
> >> JC>         }
> >> JC>       }
> >> JC>       f.elements[0].focus();
> >> JC>     }
> >> JC>     // -->
> >> JC> </script>
> >> 
> >> JC> -- Jim
> >> 
> >> JC> Rick Reumann <maillist@reumann.net> writes:
> >> 
> >> >> If the user submits a form and some server side validation is done
and
> >> >> the jsp form returns to the user with some validation, what is the
> >> >> best way to allow the user to clear the form and start over. Having
a
> >> >> <html:reset> button whill only clear new things they enter, and
> >> >> refreshing is currently returning the same form with the same
> >> >> validation errors. I was thinking maybe having a button labeled
> >> >> "reset" but what it actually does is submit to an action that clears
> >> >> out all the fields and then returns you? Is this a good way to do it,
> >> >> or is there a better way with struts?
> >> >> 
> >> >> Thanks for any feedback.
> >> >> 
> >> >> 
> >> >> -- 
> >> >> 
> >> >> Rick
> >> >> mailto:maillist@reumann.net
> >> >> 
> >> >> "Why do people in ship mutinies always ask for 'better treatment'?
I'd
> >> >> ask for a pinball machine, because with all that rocking back and
> >> >> forth you'd probably be able to get a lot of free games." 
> >> >>   -Jack Handey
> >> >> 
> >> >> 
> >> >> --
> >> >> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> >> >> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
> >> 
> >> 
> >> 
> >> -- 
> >> 
> >> Rick
> >> mailto:maillist@reumann.net
> >> 
> >> "The difference between a man and a boy is, a boy wants to grow up to
> >> be a fireman, but a man wants to grow up to be a giant monster
> >> fireman." 
> >>   -Jack Handey
> >> 
> >> 
> >> --
> >> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> >> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
> 
> 
> 
> -- 
> 
> Rick
> mailto:maillist@reumann.net
> 
> "There's nothing so tragic as seeing a family pulled apart by
> something as simple as a pack of wolves." 
>   -Jack Handey
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>

-- 
Jim Crossley
http://www.lads.com/~jim

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