On 5/3/07, Sandra Reichert <[EMAIL PROTECTED]> wrote:
Hi,

Our web application offers two ways for data input.
The first way is an html from. Here the user can enter record by record.
Validation works fine.
The second way is to import data from a .cvs file. I want to use the
same validation.xml file for the validation of these data.

But this Exception occurs:
org.apache.commons.validator.ValidatorException: No ValidatorAction
named required found for field fieldname
        at 
org.apache.commons.validator.Field.handleMissingAction(Field.java:867)
        at org.apache.commons.validator.Field.validate(Field.java:843)
        at org.apache.commons.validator.Form.validate(Form.java:290)
        at org.apache.commons.validator.Validator.validate(Validator.java:354)


Abstract from UploadAction:
//--------------------------
InputStream in =
this.getClass().getResourceAsStream("validation.xml");
ValidatorResources resources = new ValidatorResources(in);
                                                                        // 
Construct validator based on the loaded
// resources and the form key
                                                                        Validator 
validator = new Validator(resources, "GeneForm");
                                                                        // add 
the name bean to the validator as a                                      // 
resource for
the validations to be performed on.
                                                                        
validator.setParameter(Validator.BEAN_PARAM, importGene);
                                                                        // Get 
results of the validation.
ValidatorResults results = null;
results = validator.validate(); // here the exception occurs
//----------------------------------

Whats`s my mistake?

It can't find a validator named "required" - for a Struts webapp most
people use the validator-rules.xml shipped with Struts which defines
all the standard validators. Looks like you are just using your custom
rules.

So you could do something like the following:

 InputStream[] streams = new InputStream[2];
 streams[0] = this.getClass().getResourceAsStream("validator-rules.xml");
 streams[1] = this.getClass().getResourceAsStream("validation.xml");
 ValidatorResources resources = new ValidatorResources(streams);

Niall


Thanks a lot
Sandra

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

Reply via email to