struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From runningoutofw...@netscape.net (Ying)
Subject Re: Re: questions about struts validator
Date Thu, 16 Jan 2003 14:49:21 GMT
>> This is the scenario that I was trying to figure out.
>> Suppose in the struts config file I've defined a form bean name
>"logonForm"
>> and an action named "/logon" which uses "logonForm". And suppose that
>> in validate.xml I've defined
>>   <formset>
>>     <form name="logon">
>>        ...
>>     </form>
>>     <form name="logonForm">
>>        ...
>>     </form>
>>   </formset>
>>
>
>The first form entry does not make sense. The name attribute in the form
>element should be the logical name you assigned to the form bean in the
>Struts config file and not the action name.

The first form entry is possible because of the ValidatorActionForm class.
from:

http://jakarta.apache.org/struts/api/org/apache/struts/validator/ValidatorActionForm.html

"This class extends ValidatorForm and provides basic field validation based on an XML file.
The key passed into the validator is the action element's 'path' attribute from the struts-config.xml
which should match the form element's name attribute in the validation.xml."

So - I have an action name logon, and form bean logonForm which extends
ValidatorActionForm.  Action logon uses logonForm. I am guessing that -
when the path of action is executed, the "logon" validation entry gets
executed (and ignores the "logonForm" entry?)...

There is probably something missing from my question (due to probably still
lack of understanding of this). I'll have to just play with it :)
Thanks for having patience..

>> When the user clicks on a button that triggers a form submit
>> via the logon action...  What validation takes place?
>>
>> Maybe my question should be:  When does validation for form bean
>> gets triggered?  Is it any time that an action uses it or?
>>
>
>Since I don't know what your action mapping entry looks like, I will make a
>couple of  assumptions in addition to what you have stated: validation is
>enabled and the form bean is in request scope.
>
>Suppose that a request arrives for the "/logon" action path. Struts will
>first look for an attribute in the request called "logonForm" (by default
>Struts stores your form bean as an attribute using the same name as the
>logical name you gave it). In this case, it will not find your form bean in
>the request. Struts will therefore create an instance of your form bean,
>store it in the request as an attribute under the name "logonForm", call the
>reset method on it, populate it with request parameters that match setters
>in your form bean and finally call the validate method on your form bean. If
>validation succeeds (the validate method returns null or an empty
>collection), Struts will then call the execute method on the associated
>Action object. Every time a request arrives for the "/logon" action path,
>this sequence will repeat.

Thanks for the explaination!

Ying


__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp


Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

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