DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17104>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17104 Newbie FAQ - When is the best time to validate input? Summary: Newbie FAQ - When is the best time to validate input? Product: Struts Version: Unknown Platform: All OS/Version: All Status: NEW Severity: Enhancement Priority: Other Component: Documentation AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] <p>This is an excellent question. Let's step back a second and think about a typical mid to large size application. If we start from the back end and work toward the view we have:</p> <p>1) Database: Most modern databases are going to validate for required fields, duplicate records, security constraints, etc.</p> <p>2) Business Logic: Here you are going to check for valid data relationships and things that make sense for the particular problem you are triing to solve.</p> <p>... This is where struts comes into the picture, by now the system should be pretty well bulletproof. What we are going to do is make validation friendlier and informative. Rember it is OK to have duplicate validations...</p> <p>3) <code>ActionErrors validate(ActionMapping map, HttpServletRequest req) </code> is where you can do your validation and feed back to the view, information required to correct any errors. <code>validate</code> is run after the form has been <code>reset</code> and after the <code>ActionForm</code> properties have been set from corresponding view based input. Also remember you can turn validation off with <code>validate="false"</code> in the <code>action</code> mapping in the <code>struts-config.xml</code>. This is done by returning an <code>ActionErrors</code> collection with messages from your <code>ApplicationResources.properties</code> file.</p> <p>Here you have access to the request so you can see what kinds of action is being requested to fine tune your validations. The <html:error> tag allows you to dump all errors on your page or a particular error associated with a particular property. The <code>input</code> attribute of the <code>struts-config.xml</code> <code>action</code> allows you to send validation errors to a particular jsp / html / tile page.</p> <p>4) You can have the system perform low level validations and client side feedback using a <code>ValidatorForm</code> or its derivatives. This will generate javascript and give instant feedback to the user for simple data entry errors. You code your validations in the <code>validator-rules.xml</code> file. A working knowledge of <a href="http://etext.lib.virginia.edu/helpsheets/regex.html">regular expressions</a> is necessary to use this feature effectively. For more information <p><a href="http://jakarta.apache.org/struts/userGuide/dev_validator.html">http://jaka rta.apache.org/struts/userGuide/dev_validator.html</a></p> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
