You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by cilquirm <aa...@gmail.com> on 2007/02/21 17:04:57 UTC

Re: [S2] struts2 validation for only one method in action

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


Re: struts2 validation for only one method in action

Posted by shan99 <ra...@gmail.com>.

I have 2 mothods caled edit() and create() I used annotation based
validation
but tthing is i want to validate some of experssions in edit method and some
of the in create() method
cant use @skipValidation in this
my problem is i can not difine this seperatly in my actiion class ..both
methods get validate from all expressions? any 1 have a ida?
-- 
View this message in context: http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a13249573
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


Re: [S2] struts2 validation for only one method in action

Posted by Allen Gilliland <al...@sun.com>.

Dale Newfield wrote:
> Allen Gilliland wrote:
>> Would you mind sharing a couple details about how you have it 
>> configured, because if it's working for you then I suppose I must be 
>> doing something wrong?  I am using Struts 2.0.5.
> 
> Sure.  I'll just mirror your snippets with my own.  I am also using 2.0.5.
> 
>> What I have in my struts.xml file is ...
>>
>> <action name="MyForm!*" method="{1}" class="mypackage.MyForm">
>>    <result name="input">/WEB-INF/jsps/MyForm.jsp</result>
>> </action>
> 
> I have explicit mappings for each action, so what the the validation.xml 
> file should be named is easier to see:
> 
>         <action name="editProfile" class="userAction" method="edit">
>             <result name="success">/WEB-INF/pages/userForm.jsp</result>
>             <result name="error">/WEB-INF/pages/userHome.jsp</result>
>         </action>
> 
>         <action name="saveUser" class="userAction" method="save">
>             <result name="cancel" type="redirect">users.xhtml</result>
>             <result name="input">/WEB-INF/pages/userForm.jsp</result>
>             <result name="success" type="redirect">users.xhtml</result>
>             <result name="addAnother" 
> type="redirect">editUser.xhtml?method=Add&amp;from=list</result>
>         </action>
> 
> and I have UserAction-saveUser-validation.xml

ahhh, that would probably make it easier.  i don't think i ever played 
with it enough to try that because i'm lazy :/


> 
> for you, I'm tempted to say the file should be 
> MyForm!*-save-validation.xml ? or maybe MyForm!save-validation.xml (no 
> method, but a more specific action name?)   I'd bet your problem is what 
> that struts is looking for the wrong file.  Any way to stick in some 
> logging to tell you what it thinks the action name is, and what it 
> thinks the method name is?

you are right, the problem was that I just didn't have the right name 
for the validation file and you example helped me figure out why.  i 
guess it isn't enough to just put the method name in the middle part of 
the validation file name, it needs the full action name including the 
method for it to work.  so this is what works ...

MyForm-MyForm!save-validation.xml

seems a little redundant, but at least it's working =)  thanks for the help!

is there a wiki page or something that i should be adding this too?  i 
think the current documentation ...

http://struts.apache.org/2.x/docs/validation.html
http://struts.apache.org/2.x/docs/action-configuration.html#ActionConfiguration-WildcardMethod

didn't really show exactly the right thing to do, so it would help to 
fix those up.

-- Allen


> 
>> Using this I can access MyForm.action to get to the default view 
>> showing an empty form, and I can post the form to MyForm!save.action 
>> and it executes the save() method on my action.
> 
> My urls would be "/editProfile.xhtml" and "/saveUser.xhtml"
> 
>> Then in mypackage I have a file called MyForm-save-validation.xml with 
>> this in it ...
>>
>> <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 
>> 1.0.2//EN"
>>        "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
>> <validators>
>>   <field name="property">
>>       <field-validator type="requiredstring">
>>           <param name="trim">true</param>
>>           <message>property is required</message>
>>       </field-validator>
>>   </field>
>> </validators>
> 
> <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 
> 1.0.2//EN"
>     "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
> <validators>
>     <field name="user">
>         <field-validator type="visitor">
>             <param name="appendPrefix">false</param>
>             <message/>
>         </field-validator>
>     </field>
> </validators>
> 
> One part of my User-validation.xml includes:
> 
>     <field name="user.address.city">
>         <field-validator type="requiredstring">
>             <message key="errors.required"/>
>         </field-validator>
>     </field>
> 
> and I just tested that if I try to change my address to have no city the 
> validation rejects the form submission and sends me back to the form 
> with errors added in the appropriate places.
> 
>> If I define just MyForm-validation.xml it works as expected and is 
>> called to validate on all methods used on the action, but nothing 
>> happens when I just have the MyForm-save-validation.xml file.
> 
> I'd bet due to the expanded-at-runtime nature of your action definition 
> that the file it's looking for is not the one you'd expect it to be 
> looking for.  I can attest that if it finds the method-specific file it 
> does perform the validation.  This isn't a solution, but it at least 
> gives you a more specific portion of the struts code to dig through. :-)
> 
>>> Just because the ActionName-validation.xml file is no longer in your 
>>> .war doesn't mean it's been removed from the directory tree where 
>>> your container expands stuff...
>>
>> True, but that's why I clean that out each time I update my app. 
>> Besides, my real problem is not that the 2 files are conflicting with 
>> each other, it's that when I just have a 
>> ActionName-MethodName-validation.xml file then nothing happens.  No 
>> validation on that action at all.
> 
> I was assuming you had the same problem I had:  Back when I had a 
> form-validation.xml file and I realized I just wanted it to happen for a 
> single method, I changed the name to form-method-validation.xml, but it 
> took me 20 minutes to figure out why I was still failing the validation 
> that shouldn't have been happening--I'd never removed the 
> form-validation.xml file from tomcat's work directory :-)
> 
> -Dale
> 
> ---------------------------------------------------------------------
> 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


Re: [S2] struts2 validation for only one method in action

Posted by Dale Newfield <Da...@Newfield.org>.
Allen Gilliland wrote:
> Would you mind sharing a couple details about how you have it 
> configured, because if it's working for you then I suppose I must be 
> doing something wrong?  I am using Struts 2.0.5.

Sure.  I'll just mirror your snippets with my own.  I am also using 2.0.5.

> What I have in my struts.xml file is ...
> 
> <action name="MyForm!*" method="{1}" class="mypackage.MyForm">
>    <result name="input">/WEB-INF/jsps/MyForm.jsp</result>
> </action>

I have explicit mappings for each action, so what the the validation.xml 
file should be named is easier to see:

         <action name="editProfile" class="userAction" method="edit">
             <result name="success">/WEB-INF/pages/userForm.jsp</result>
             <result name="error">/WEB-INF/pages/userHome.jsp</result>
         </action>

         <action name="saveUser" class="userAction" method="save">
             <result name="cancel" type="redirect">users.xhtml</result>
             <result name="input">/WEB-INF/pages/userForm.jsp</result>
             <result name="success" type="redirect">users.xhtml</result>
             <result name="addAnother" 
type="redirect">editUser.xhtml?method=Add&amp;from=list</result>
         </action>

and I have UserAction-saveUser-validation.xml

for you, I'm tempted to say the file should be 
MyForm!*-save-validation.xml ? or maybe MyForm!save-validation.xml (no 
method, but a more specific action name?)   I'd bet your problem is what 
that struts is looking for the wrong file.  Any way to stick in some 
logging to tell you what it thinks the action name is, and what it 
thinks the method name is?

> Using this I can access MyForm.action to get to the default view showing 
> an empty form, and I can post the form to MyForm!save.action and it 
> executes the save() method on my action.

My urls would be "/editProfile.xhtml" and "/saveUser.xhtml"

> Then in mypackage I have a file called MyForm-save-validation.xml with 
> this in it ...
> 
> <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 
> 1.0.2//EN"
>        "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
> <validators>
>   <field name="property">
>       <field-validator type="requiredstring">
>           <param name="trim">true</param>
>           <message>property is required</message>
>       </field-validator>
>   </field>
> </validators>

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 
1.0.2//EN"
     "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
     <field name="user">
         <field-validator type="visitor">
             <param name="appendPrefix">false</param>
             <message/>
         </field-validator>
     </field>
</validators>

One part of my User-validation.xml includes:

     <field name="user.address.city">
         <field-validator type="requiredstring">
             <message key="errors.required"/>
         </field-validator>
     </field>

and I just tested that if I try to change my address to have no city the 
validation rejects the form submission and sends me back to the form 
with errors added in the appropriate places.

> If I define just MyForm-validation.xml it works as expected and is 
> called to validate on all methods used on the action, but nothing 
> happens when I just have the MyForm-save-validation.xml file.

I'd bet due to the expanded-at-runtime nature of your action definition 
that the file it's looking for is not the one you'd expect it to be 
looking for.  I can attest that if it finds the method-specific file it 
does perform the validation.  This isn't a solution, but it at least 
gives you a more specific portion of the struts code to dig through. :-)

>> Just because the ActionName-validation.xml file is no longer in your 
>> .war doesn't mean it's been removed from the directory tree where your 
>> container expands stuff...
> 
> True, but that's why I clean that out each time I update my app. 
> Besides, my real problem is not that the 2 files are conflicting with 
> each other, it's that when I just have a 
> ActionName-MethodName-validation.xml file then nothing happens.  No 
> validation on that action at all.

I was assuming you had the same problem I had:  Back when I had a 
form-validation.xml file and I realized I just wanted it to happen for a 
single method, I changed the name to form-method-validation.xml, but it 
took me 20 minutes to figure out why I was still failing the validation 
that shouldn't have been happening--I'd never removed the 
form-validation.xml file from tomcat's work directory :-)

-Dale

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


Re: [S2] struts2 validation for only one method in action

Posted by Allen Gilliland <al...@sun.com>.

Dale Newfield wrote:
> Allen Gilliland wrote:
>> 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 :/
> 
> I use the ActionName-methodName-validation.xml technique.

Would you mind sharing a couple details about how you have it 
configured, because if it's working for you then I suppose I must be 
doing something wrong?  I am using Struts 2.0.5.

What I have in my struts.xml file is ...

<action name="MyForm!*" method="{1}" class="mypackage.MyForm">
    <result name="input">/WEB-INF/jsps/MyForm.jsp</result>
</action>

Using this I can access MyForm.action to get to the default view showing 
an empty form, and I can post the form to MyForm!save.action and it 
executes the save() method on my action.

Then in mypackage I have a file called MyForm-save-validation.xml with 
this in it ...

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 
1.0.2//EN"
        "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
   <field name="property">
       <field-validator type="requiredstring">
           <param name="trim">true</param>
           <message>property is required</message>
       </field-validator>
   </field>
</validators>

If I define just MyForm-validation.xml it works as expected and is 
called to validate on all methods used on the action, but nothing 
happens when I just have the MyForm-save-validation.xml file.


> 
> Just because the ActionName-validation.xml file is no longer in your 
> .war doesn't mean it's been removed from the directory tree where your 
> container expands stuff...

True, but that's why I clean that out each time I update my app. 
Besides, my real problem is not that the 2 files are conflicting with 
each other, it's that when I just have a 
ActionName-MethodName-validation.xml file then nothing happens.  No 
validation on that action at all.

-- Allen


> 
> -Dale
> 
> ---------------------------------------------------------------------
> 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


Re: [S2] struts2 validation for only one method in action

Posted by Dale Newfield <Da...@Newfield.org>.
Allen Gilliland wrote:
> 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 :/

I use the ActionName-methodName-validation.xml technique.

Just because the ActionName-validation.xml file is no longer in your 
.war doesn't mean it's been removed from the directory tree where your 
container expands stuff...

-Dale

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


Re: [S2] struts2 validation for only one method in action

Posted by Allen Gilliland <al...@sun.com>.
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 <aa...@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


Re: [S2] struts2 validation for only one method in action

Posted by Allen Gilliland <al...@sun.com>.

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 <aa...@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


Re: [S2] struts2 validation for only one method in action

Posted by Allen Gilliland <al...@sun.com>.
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.

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 <aa...@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


Re: [S2] struts2 validation for only one method in action

Posted by André Faria <an...@mandic.com.br>.
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 <aa...@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
>>
>>
>
>


-- 
Atenciosamente,
*/André Faria/*
/Bluesoft Consultoria em Informática/
/Fone: [55 11] 5543-5406/
/e-mail: andrefaria@bluesoft.com.br/
/Web: www.bluesoft.com.br/
////////

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


Re: struts2 validation for only one method in action

Posted by Igor Vlasov <vi...@mail.ru>.
Thank you for your answer. It was very helpful.



Ian Roughley wrote:
> 
> you can always use <s:submit name="method:delete" value="Delete" /> and 
> <s:submit value="Execute" /> - then you don't need the logic to 
> determine which button was clicked in the execute() method, and you can 
> use the validation config below.
> 
> /ian
> 
> Igor Vlasov wrote:
>> This is not a solution.
>>
>> I have 2 submit button in one form: one for save and another for delete.
>> All
>> of them submit the form data to execute() method. There I can determine
>> which button was pressed and do  an appropriate bussines action.
>>
>> The problem is that i must to validate the data when "OK" button is
>> pressed
>> and  NOT validate when "DEL" button is pressed.
>>
>>
>> ros wrote:
>>   
>>> For struts it's                 
>>> <interceptor-ref name="validation">
>>>     cancel,execute,delete,edit,list,print
>>> </interceptor-ref>
>>>
>>> Hope this helps.
>>>
>>> ros
>>>
>>>
>>> Igor Vlasov wrote:
>>>     
>>>> And how to disable the SERVER side validation when delete button
>>>> clicked
>>>> ?
>>>>
>>>>
>>>>
>>>> ros wrote:
>>>>       
>>>>> Java Script validation fro button disabled by 
>>>>>
>>>>> <s:submit cssClass="button" method="delete" key="button.delete"
>>>>>                        
>>>>> onclick="document.getElementById('ticketForm').onsubmit = null;" />
>>>>>
>>>>>
>>>>> ros wrote:
>>>>>         
>>>>>> If I have in one form DELETE and SAVE buttons, how to turn off client
>>>>>> side validation for DELETE button?
>>>>>>
>>>>>>           
>>>>>         
>>>>       
>>>     
>>
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a13269628
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


Re: struts2 validation for only one method in action

Posted by Ian Roughley <ia...@fdar.com>.
you can always use <s:submit name="method:delete" value="Delete" /> and 
<s:submit value="Execute" /> - then you don't need the logic to 
determine which button was clicked in the execute() method, and you can 
use the validation config below.

/ian

Igor Vlasov wrote:
> This is not a solution.
>
> I have 2 submit button in one form: one for save and another for delete. All
> of them submit the form data to execute() method. There I can determine
> which button was pressed and do  an appropriate bussines action.
>
> The problem is that i must to validate the data when "OK" button is pressed
> and  NOT validate when "DEL" button is pressed.
>
>
> ros wrote:
>   
>> For struts it's                 
>> <interceptor-ref name="validation">
>>     cancel,execute,delete,edit,list,print
>> </interceptor-ref>
>>
>> Hope this helps.
>>
>> ros
>>
>>
>> Igor Vlasov wrote:
>>     
>>> And how to disable the SERVER side validation when delete button clicked
>>> ?
>>>
>>>
>>>
>>> ros wrote:
>>>       
>>>> Java Script validation fro button disabled by 
>>>>
>>>> <s:submit cssClass="button" method="delete" key="button.delete"
>>>>                        
>>>> onclick="document.getElementById('ticketForm').onsubmit = null;" />
>>>>
>>>>
>>>> ros wrote:
>>>>         
>>>>> If I have in one form DELETE and SAVE buttons, how to turn off client
>>>>> side validation for DELETE button?
>>>>>
>>>>>           
>>>>         
>>>       
>>     
>
>   

Re: struts2 validation for only one method in action

Posted by Igor Vlasov <vi...@mail.ru>.
This is not a solution.

I have 2 submit button in one form: one for save and another for delete. All
of them submit the form data to execute() method. There I can determine
which button was pressed and do  an appropriate bussines action.

The problem is that i must to validate the data when "OK" button is pressed
and  NOT validate when "DEL" button is pressed.


ros wrote:
> 
> For struts it's                 
> <interceptor-ref name="validation">
>     cancel,execute,delete,edit,list,print
> </interceptor-ref>
> 
> Hope this helps.
> 
> ros
> 
> 
> Igor Vlasov wrote:
>> 
>> And how to disable the SERVER side validation when delete button clicked
>> ?
>> 
>> 
>> 
>> ros wrote:
>>> 
>>> Java Script validation fro button disabled by 
>>> 
>>> <s:submit cssClass="button" method="delete" key="button.delete"
>>>                        
>>> onclick="document.getElementById('ticketForm').onsubmit = null;" />
>>> 
>>> 
>>> ros wrote:
>>>> 
>>>> If I have in one form DELETE and SAVE buttons, how to turn off client
>>>> side validation for DELETE button?
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a13254948
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


Re: struts2 validation for only one method in action

Posted by ros <ro...@palivoda.id.lv>.
For struts it's                 
<interceptor-ref name="validation">
    cancel,execute,delete,edit,list,print
</interceptor-ref>

Hope this helps.

ros


Igor Vlasov wrote:
> 
> And how to disable the SERVER side validation when delete button clicked ?
> 
> 
> 
> ros wrote:
>> 
>> Java Script validation fro button disabled by 
>> 
>> <s:submit cssClass="button" method="delete" key="button.delete"
>>                        
>> onclick="document.getElementById('ticketForm').onsubmit = null;" />
>> 
>> 
>> ros wrote:
>>> 
>>> If I have in one form DELETE and SAVE buttons, how to turn off client
>>> side validation for DELETE button?
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a13254840
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


Re: struts2 validation for only one method in action

Posted by Igor Vlasov <vi...@mail.ru>.
And how to disable the SERVER side validation when delete button clicked ?



ros wrote:
> 
> Java Script validation fro button disabled by 
> 
> <s:submit cssClass="button" method="delete" key="button.delete"
>                        
> onclick="document.getElementById('ticketForm').onsubmit = null;" />
> 
> 
> ros wrote:
>> 
>> If I have in one form DELETE and SAVE buttons, how to turn off client
>> side validation for DELETE button?
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a13253735
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


Re: [S2] struts2 validation for only one method in action

Posted by ros <ro...@palivoda.id.lv>.
Java Script validation fro button disabled by 

<s:submit cssClass="button" method="delete" key="button.delete"
                       
onclick="document.getElementById('ticketForm').onsubmit = null;" />


ros wrote:
> 
> If I have in one form DELETE and SAVE buttons, how to turn off client side
> validation for DELETE button?
> 

-- 
View this message in context: http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a9086501
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


Re: [S2] struts2 validation for only one method in action

Posted by ros <ro...@palivoda.id.lv>.
I assume for action:
public class TicketAction extends com.opensymphony.xwork2.ActionSupport {
...
 public string save() {
...
 }
...
}
the file name should be  TicketAction-save-validation.xml ???

File with such name is ignored on form submit.

Only TicketAction-validation.xml is valid file name.

Any ideas, why?

If I have in one form DELETE and SAVE buttons, how to turn off client side
validation for DELETE button?

Thanks.


Musachy Barroso wrote:
> 
> 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 <aa...@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
>>
>>
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> 

-- 
View this message in context: http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a9085071
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


Re: [S2] struts2 validation for only one method in action

Posted by Musachy Barroso <mu...@gmail.com>.
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 <aa...@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
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: [S2] struts2 validation for only one method in action

Posted by reijnemans <dr...@e-id.nl>.


cilquirm 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.
>> 
> 
> 

You can disable one action with the annotation

@org.apache.struts2.interceptor.validation.SkipValidation
-- 
View this message in context: http://www.nabble.com/struts2-validation-for-only-one-method-in-action-tf3267302.html#a9144299
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