Direct the user to an action that isn't the action associated with the
page in question, even if all that action does is forward to the JSP
page.  Generally the action's associated with a JSP page get called from
that JSP page.

ActionA forwards to B.JSP, B.JSP submits to ActionB and so on...

Alternately provide a hidden form variable in your page, in your
validation method, check for it, if it's not there, don't continue
validating as the user did not just submit the page.

Robert Nocera
New England Open Solutions
www.neosllc.com
"You supply the vision, we'll do the rest."
 

-----Original Message-----
From: Sid Stuart [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, February 05, 2002 12:25 PM
To: Struts Users Mailing List
Subject: Design question about ActionForm's validate method

Hi,

I've stumbled across a subtle problem/design question that I don't see
mentioned in the documentation.

The ActionForm's validate method can be configured to verify form data
from a page and generate error messages which may then be displayed on
the page for the user to see. This works fine when the user has accessed
the page by specifying a JSP file in the URL. When the user accesses the
page by calling the Action directly though, the validate method is
called before the user ever sees the page, much less inputs valid data
to the form. This leads to an unfortunate display of unwarranted error
messages.

It would be nice if the documentation would provide a rule such as:
If one plans on the user calling the Action directly in the URL  then
one should not use the automatic validation provided by ActionForm.

Further, as having two different procedures to generate a page can lead
to subtle errors, one should decide whether a page will be accessed as a
JSP or as an Action and design for the one scenario. The simplest (and
safest) design rule will be to access all pages through either one
mechanism or the other.

Comments?

Sid Stuart




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to