struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Allen Gilliland <allen.gillil...@sun.com>
Subject Re: [S2] struts2 validation for only one method in action
Date Thu, 22 Feb 2007 19:15:20 GMT
I tried out using the validation annotations to only validate a specific 
action method but the result is the same, it just does the validation on 
all methods :/

This is what I tried ...

@Validation()
public class MyAction extends ActionSupport {

   ... yada yada ...

   public String execute() {
         return INPUT;
     }


     @Validations(
             requiredStrings =
 
{@RequiredStringValidator(type=ValidatorType.SIMPLE, 
fieldName="myfield", message="myfield is required")}
     )
     public String save() {

         ... save method ...

     }

}

Anyone else have an idea on how to configure validation on only a 
specific action method?

-- Allen


Allen Gilliland wrote:
> 
> 
> Allen Gilliland wrote:
>> Do you have a link to some docs on how to use annotations to specify 
>> validation rules?  I haven't seen anything about that yet.
> 
> ack, never mind, i see the link now :/
> 
> http://struts.apache.org/2.x/docs/validation-annotation.html
> 
> 
>>
>> I am attempting to do the same thing and it definitely isn't working 
>> properly.  If you simply use a validator for the entire Action defined 
>> in ActionName-validation.xml then it works (and gets applied to all 
>> methods), but ActionName-MethodName-validation.xml does not get picked 
>> up.
>>
>> -- Allen
>>
>>
>> André Faria wrote:
>>> Ok, but what about annotations without xmls?
>>>
>>> Musachy Barroso escreveu:
>>>> See here:
>>>>
>>>> http://struts.apache.org/2.x/docs/validation.html
>>>>
>>>> you can add a file ActionName-MethodName-validation.xml with the 
>>>> validation
>>>> for that method.
>>>>
>>>> regards
>>>> musachy
>>>>
>>>> On 2/21/07, cilquirm <aadi.deshpande@gmail.com> wrote:
>>>>>
>>>>>
>>>>> I believe you can use validation annotation to specify validation 
>>>>> routines
>>>>> at
>>>>> the method level.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ros wrote:
>>>>> >
>>>>> > Hi!
>>>>> >
>>>>> > How to configure struts2 validation for only one method in action?
>>>>> >
>>>>> > Thanks.
>>>>> >
>>>>>
>>>>> -- 
>>>>> View this message in context:
>>>>> http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a9083597

>>>>>
>>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

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


Mime
View raw message