I tried using Car-validation.xml too and it doesnt work, anything else I could try?

Jason Carreira wrote:
It should be Car-validation.xml, not Car-validations.xml


-----Original Message-----
From: Francisco Hernandez [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 1:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] using one validator on several different actions



ok, so this is what i've got and its not working, maybe im not understanding everyting correctly, in CarAction-validation.xml :


<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd";>
<validators>


    <field name="car">
        <field-validator type="visitor">
            <!--param name="context">create</param-->
            <message>Car Visitor: </message>
        </field-validator>
    </field>


</validators>



------------------------


in Car-validations.xml:

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd";>
<validators>


    <field name="name">
        <field-validator type="requiredstring">
            <message>Name is REQUIRED</message>
        </field-validator>
    </field>
    <field name="model">
        <field-validator type="requiredstring">
            <message>Model is REQUIRED</message>
        </field-validator>
    </field>

</validators>
---------------------------

in my CarAction I have a car object exposed and my field names for the forms I use car.name, car.model etc, both validation files are in the same package as the CarAction, what am I doing wrong here?



Jason Carreira wrote:


If you have the Car object as a property of the Action, you can use the VisitorFieldValidator (there's a little doc on this on

the Wiki)


to make the validation framework use the validations

defined for the


Car class. This way, you could define your common

validations for the


car in a single Car-validations.xml. You could also define context-specific validations for Car by creating Car-edit-validation.xml and Car-create-validation.xml and set the context in the VisitorFieldValidator declaration, like this:

   <field name="car">
       <field-validator type="visitor">
           <param name="context">anotherContext</param>
           <message>car: </message>
       </field-validator>
   </field>

Here, the message element defines the text which is

prepended to the


messages added by the validators for the subproperty (car in this case). The VisitorFieldValidator can also be applied to Collections and Arrays of objects and will run for each.

Jason



-----Original Message-----
From: Francisco Hernandez [mailto:[EMAIL PROTECTED]
Sent: Friday, September 05, 2003 5:41 AM
To: [EMAIL PROTECTED]
Subject: [OS-webwork] using one validator on several

different actions



I've been using the validator in webwork and have found myself
duplicating a few of the validations throughout the app, is there anyway I can apply validations to multiple actions or objects?


for example I have a creation form to create a Car, and then I have
another to Edit and Update the Car, how could I create just one validation file that will validate that Car?


right now I've got 2 validation files,

CreateCarAction-validation.xml


and UpdateCarAction-validation.xml and both are identical.

im thinking maybe a way to specify what validation files to
use in the action mapping? what do you guys think





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Opensymphony-webwork mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf _______________________________________________
Opensymphony-webwork mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork









-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf _______________________________________________
Opensymphony-webwork mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork





------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork








------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to