You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sandra Reichert <re...@bni-hamburg.de> on 2007/05/03 12:19:13 UTC

ValidatorException: No ValidatorAction named required found for field fieldname

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?

Thanks a lot
Sandra



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ValidatorException: No ValidatorAction named required found for field fieldname

Posted by Niall Pemberton <ni...@gmail.com>.
On 5/3/07, Sandra Reichert <re...@bni-hamburg.de> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org