struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Ciasnocha ...@struts.cz>
Subject Re: Struts2 and Validation issue
Date Thu, 17 Feb 2011 07:47:27 GMT
Hi,

the problem of validation through annotations is they are applied every 
time the action is called. You can try use method which you call from 
your form. For example, if you want to validate only execute method, 
write your own method with name validateExecute(). The principle is same 
for another methods.

I hope this helps.

aum strut wrote on 16.2.2011 15:16:
> Hi All,
>
> I am trying to user Validation framework with Struts2 but struck at a
> point,here are the details.
>
> I am developing a import service which includes various steps like
>
> 1) Showing number of import options
>
> 2) Showing number of elgible files for the import (Import type selected in
> step one)
>
> for all this i have created only one action with multiple methods which is
> doing all the job.now in the second case when user select a file,i am trying
> to place a validation for empty field but since property file is outside of
> all he methods so the validation is working for all methods
>
> e.g
>
> i do not want the validation to execute for step1  but it is even getting
> executed for step one (since file will be selected in step 2 so step1 is
> always fails)
>
> is there any way to organise validation so that it should only execute for a
> specific method inside the Action
>
> here is my validation code
>
> @RequiredFieldValidator
>
> (type=ValidatorType.*FIELD*,message="Please select a file for import")
>
>
>
>
> *public* String getSelectedFile() {
>
>
>
>
> *return* selectedFile;
>
>
>
>
> }
>
> any help in this regard will be appriciated
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message