You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Keith Bacon <ke...@yahoo.com> on 2001/12/06 15:54:46 UTC
Seperate Actions For Form Init & Validation (was JSPs past WEB-INF --- Please Help!)
My way may be no better!
I have a hidden variable called formName on every
form, set to a literal value. I code the same name in
that forms action class.
Then at top of the perform method in the action class,
if the 2 values are equal I know I was started from my
form being submitted so I validate.
Otherwise I don't validate but do initialisation of
the form.
There's a similarity to struts tokens here - maybe we
need 2 types of token?
Form Version Token
- checks submission is from my form & from the latest
version of it I sent (not some old cached version).
Form Name Token
- checks submission is from my form.
--------
Note that your action classes have these functions
1 - Prepare for initial form display
2 - xfer to this forms JSP (forward to input mapping).
3 - Validate form input
4 - If Valid xfer to next function (forward to success
mapping)
5 - If invalid xfer to this forms jsp (forward to
input mapping)
I have all this in 1 action class & use only 1 action
mapping.
Other people have an action mapping & class for the
initial send & another for the validation.
The 3rd way (Alexanders) is 2 action mappings using 1
action class
I don't have enough experience to say which is best!
-----
Keith.
--- Dave J Dandeneau <Da...@viant.com> wrote:
> That makes sense. This is such a common occurence
> that I figured there
> would be a better way.
>
> Thanks for the help!
> Dave
>
>
> -----Original Message-----
> From: Alexander Jesse
> [mailto:alexander.jesse@csfs.com]
> Sent: Thursday, December 06, 2001 2:26 AM
> To: struts-user
> Subject: RE: JSPs past WEB-INF --- Please Help!
>
>
> I usually use the same action with two mappings (one
> with validation,
> one without) and the parameter-setting to
> distinguish between the
> two situations...
>
> Yes you get two mappings, but at least the important
> stuff (java-code)
> is reused...
>
> hope this helps
> Alexander Jesse
>
> -----Original Message-----
> From: Dave.Dandeneau@viant.com
> [mailto:Dave.Dandeneau@viant.com]
> Sent: Wednesday, December 05, 2001 9:31 PM
> To: struts-user@jakarta.apache.org
> Subject: JSPs past WEB-INF --- Please Help!
>
>
> I have been trying to figure this out for a while
> now, but have had no
> luck. Any help would be soooo greatly appreciated.
> Here it is:
>
> If you place your jsps past the WEB-INF and do not
> hit them directly
> then what is the easiest way to implement a
> "first-visit". i.e. the
> first time you go to a page it doesn't show the
> errors, but each other
> time it does? I have done this otherwise by having
> them go directly to
> the jsp the first time, and then having them submit
> to the action, but I
> can't send them directly to the JSP if it is past
> the WEB-INF. I have
> also done this by creating a new mapping that set
> validate="false", but
> then there is some duplication as far as the
> mappings. Is there any
> easier way to do it?
>
> Thanks for the help in advance,
> dave dandeneau
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>