You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bionicoder <bi...@hotmail.com> on 2007/11/27 09:16:08 UTC

S2: Struts2 @SkipValidation does not work

Hi,

I want to disable validation for certain Struts 2 method. For example, in
the following action class,

public class CustomerAction extends ActionSupport  {
       private Customer customer;

       public String input() {
             return INPUT;
       }

       public String save() {
             return SUCCESS;
       }
      
       @SkipValidation
       public String  list() {
             List l = new ArrayList();
             l = getCustomerList();

             return "list";
       }

       public String execute() throws Exception {
		return SUCCESS;
	}

}

I want to disable validation for 'list' method. However, the validation
still takes effect. The symptom is if there is no input in the form before
clicking "List" button to execute 'list' method, it will return to 'INPUT"
result which is not what I want. If there is some input, for example,
checking a checkbox before clicking the 'List" button, then it will run into
'list" method and give a right result. 

Obviously, it still try to validate before executing 'list' method even
there is @SkipValidation annotation. Has anybody come cross the similiar
problem before? The struts version is 2.0.9.

Thanks!

BC
-- 
View this message in context: http://www.nabble.com/S2%3A-Struts2-%40SkipValidation-does-not-work-tf4880341.html#a13966505
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 @SkipValidation does not work

Posted by Joachim Ansorg <ja...@ksi.gr>.
Hi,
I think an interceptor is getting in between, as you mentioned further 
down the thread.

I found out on my project that if the workflow interceptor finds error 
messages for the page the default result INPUT is returned.
You can change that with this in your own interceptor stack:
                <interceptor-ref name="workflow">
                    <param name="excludeMethods">*</param>
                    <param name="includeMethods">save</param>
                    <param name="inputResultName">error</param>
                </interceptor-ref>

This should work, too (untested):

<interceptor-stack name="mystack">
    <interceptor-ref name="default">
        <param name="workflow.excludeMethods">*</param>
        <param name="workflow.includeMethods">save</param>
        <param name="workflow.inputResultName">error</param>
    </interceptor-ref>
</interceptor-stack>

With *cludeMethods params you tell the workflow interceptor to ignore 
all except save and use error as result if there are errorMessagges for 
the save() method, I think.
Btw, the same params can be used for the validation interceptor as well 
to tell it to ignore the default validation rules for all except certain 
methods. But this doesn't affect the annotations, I think.

Joachim
> Hi,
>
> I want to disable validation for certain Struts 2 method. For example, in
> the following action class,
>
> public class CustomerAction extends ActionSupport  {
>        private Customer customer;
>
>        public String input() {
>              return INPUT;
>        }
>
>        public String save() {
>              return SUCCESS;
>        }
>       
>        @SkipValidation
>        public String  list() {
>              List l = new ArrayList();
>              l = getCustomerList();
>
>              return "list";
>        }
>
>        public String execute() throws Exception {
> 		return SUCCESS;
> 	}
>
> }
>
> I want to disable validation for 'list' method. However, the validation
> still takes effect. The symptom is if there is no input in the form before
> clicking "List" button to execute 'list' method, it will return to 'INPUT"
> result which is not what I want. If there is some input, for example,
> checking a checkbox before clicking the 'List" button, then it will run into
> 'list" method and give a right result. 
>
> Obviously, it still try to validate before executing 'list' method even
> there is @SkipValidation annotation. Has anybody come cross the similiar
> problem before? The struts version is 2.0.9.
>
> Thanks!
>
> BC
>   


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


Re: S2: Struts2 @SkipValidation does not work

Posted by Bionicoder <bi...@hotmail.com>.
Hi,

The IDE is JBoss IDE Eclipse 1.5 and the application server is JBoss 4.0.5.
Yes, the app war file has been totally cleaned and rebuilt. It does not
help.

Now I already found other workaround to solve my project problem. But I
still hope this weird problem can be figured out in order to benefit other
developers. So please continue to provide your comments if you have ideas.

My workaround is to use new interceptor stack instead of using default
interceptor stack. My new interceptor stack has less interceptors than
default stack. But it still has "validation" interceptor. Then when the app
run 'list" method, it does not do validation anymore. Actually in this
workaround, I did not use @SkipValidation anymore.

So my feeling is seems like certain interceptor in default stack override
@SkipValidation. I am not sure which one. But there maybe one.

Thanks!

BC


Marcos Mendonça wrote:
> 
> Hi
> 
> What IDE are you using? Have you tried cleaning up your app and
> rebuilding?
> 
> On Nov 27, 2007 6:29 PM, Bionicoder <bi...@hotmail.com> wrote:
>>
>> Hi Ted,
>>
>> Thanks for reply. Actually there is no validation XML for list method.
>> Also
>> I delete validation XML files for other method too. However the
>> validation
>> still take effect. that is the thing confuse me.
>>
>> Thanks again,
>>
>> BC
>>
>>
>>
>> Ted Husted wrote:
>> >
>> > How is the validation for the list alias being declared? Is there also
>> > an XML file?
>> >
>> > -Ted.
>> >
>> > On Nov 27, 2007 3:16 AM, Bionicoder <bi...@hotmail.com> wrote:
>> >>
>> >> Hi,
>> >>
>> >> I want to disable validation for certain Struts 2 method. For example,
>> in
>> >> the following action class,
>> >>
>> >> public class CustomerAction extends ActionSupport  {
>> >>        private Customer customer;
>> >>
>> >>        public String input() {
>> >>              return INPUT;
>> >>        }
>> >>
>> >>        public String save() {
>> >>              return SUCCESS;
>> >>        }
>> >>
>> >>        @SkipValidation
>> >>        public String  list() {
>> >>              List l = new ArrayList();
>> >>              l = getCustomerList();
>> >>
>> >>              return "list";
>> >>        }
>> >>
>> >>        public String execute() throws Exception {
>> >>                 return SUCCESS;
>> >>         }
>> >>
>> >> }
>> >>
>> >> I want to disable validation for 'list' method. However, the
>> validation
>> >> still takes effect. The symptom is if there is no input in the form
>> >> before
>> >> clicking "List" button to execute 'list' method, it will return to
>> >> 'INPUT"
>> >> result which is not what I want. If there is some input, for example,
>> >> checking a checkbox before clicking the 'List" button, then it will
>> run
>> >> into
>> >> 'list" method and give a right result.
>> >>
>> >> Obviously, it still try to validate before executing 'list' method
>> even
>> >> there is @SkipValidation annotation. Has anybody come cross the
>> similiar
>> >> problem before? The struts version is 2.0.9.
>> >>
>> >> Thanks!
>> >>
>> >> BC
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/S2%3A-Struts2-%40SkipValidation-does-not-work-tf4880341.html#a13979133
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/S2%3A-Struts2-%40SkipValidation-does-not-work-tf4880341.html#a14011455
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 @SkipValidation does not work

Posted by Marcos Mendonça <ma...@gmail.com>.
Hi

What IDE are you using? Have you tried cleaning up your app and rebuilding?

On Nov 27, 2007 6:29 PM, Bionicoder <bi...@hotmail.com> wrote:
>
> Hi Ted,
>
> Thanks for reply. Actually there is no validation XML for list method. Also
> I delete validation XML files for other method too. However the validation
> still take effect. that is the thing confuse me.
>
> Thanks again,
>
> BC
>
>
>
> Ted Husted wrote:
> >
> > How is the validation for the list alias being declared? Is there also
> > an XML file?
> >
> > -Ted.
> >
> > On Nov 27, 2007 3:16 AM, Bionicoder <bi...@hotmail.com> wrote:
> >>
> >> Hi,
> >>
> >> I want to disable validation for certain Struts 2 method. For example, in
> >> the following action class,
> >>
> >> public class CustomerAction extends ActionSupport  {
> >>        private Customer customer;
> >>
> >>        public String input() {
> >>              return INPUT;
> >>        }
> >>
> >>        public String save() {
> >>              return SUCCESS;
> >>        }
> >>
> >>        @SkipValidation
> >>        public String  list() {
> >>              List l = new ArrayList();
> >>              l = getCustomerList();
> >>
> >>              return "list";
> >>        }
> >>
> >>        public String execute() throws Exception {
> >>                 return SUCCESS;
> >>         }
> >>
> >> }
> >>
> >> I want to disable validation for 'list' method. However, the validation
> >> still takes effect. The symptom is if there is no input in the form
> >> before
> >> clicking "List" button to execute 'list' method, it will return to
> >> 'INPUT"
> >> result which is not what I want. If there is some input, for example,
> >> checking a checkbox before clicking the 'List" button, then it will run
> >> into
> >> 'list" method and give a right result.
> >>
> >> Obviously, it still try to validate before executing 'list' method even
> >> there is @SkipValidation annotation. Has anybody come cross the similiar
> >> problem before? The struts version is 2.0.9.
> >>
> >> Thanks!
> >>
> >> BC
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/S2%3A-Struts2-%40SkipValidation-does-not-work-tf4880341.html#a13979133
> 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 @SkipValidation does not work

Posted by Bionicoder <bi...@hotmail.com>.
Hi Ted,

Thanks for reply. Actually there is no validation XML for list method. Also
I delete validation XML files for other method too. However the validation
still take effect. that is the thing confuse me.

Thanks again,

BC


Ted Husted wrote:
> 
> How is the validation for the list alias being declared? Is there also
> an XML file?
> 
> -Ted.
> 
> On Nov 27, 2007 3:16 AM, Bionicoder <bi...@hotmail.com> wrote:
>>
>> Hi,
>>
>> I want to disable validation for certain Struts 2 method. For example, in
>> the following action class,
>>
>> public class CustomerAction extends ActionSupport  {
>>        private Customer customer;
>>
>>        public String input() {
>>              return INPUT;
>>        }
>>
>>        public String save() {
>>              return SUCCESS;
>>        }
>>
>>        @SkipValidation
>>        public String  list() {
>>              List l = new ArrayList();
>>              l = getCustomerList();
>>
>>              return "list";
>>        }
>>
>>        public String execute() throws Exception {
>>                 return SUCCESS;
>>         }
>>
>> }
>>
>> I want to disable validation for 'list' method. However, the validation
>> still takes effect. The symptom is if there is no input in the form
>> before
>> clicking "List" button to execute 'list' method, it will return to
>> 'INPUT"
>> result which is not what I want. If there is some input, for example,
>> checking a checkbox before clicking the 'List" button, then it will run
>> into
>> 'list" method and give a right result.
>>
>> Obviously, it still try to validate before executing 'list' method even
>> there is @SkipValidation annotation. Has anybody come cross the similiar
>> problem before? The struts version is 2.0.9.
>>
>> Thanks!
>>
>> BC
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/S2%3A-Struts2-%40SkipValidation-does-not-work-tf4880341.html#a13979133
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 @SkipValidation does not work

Posted by Ted Husted <hu...@apache.org>.
How is the validation for the list alias being declared? Is there also
an XML file?

-Ted.

On Nov 27, 2007 3:16 AM, Bionicoder <bi...@hotmail.com> wrote:
>
> Hi,
>
> I want to disable validation for certain Struts 2 method. For example, in
> the following action class,
>
> public class CustomerAction extends ActionSupport  {
>        private Customer customer;
>
>        public String input() {
>              return INPUT;
>        }
>
>        public String save() {
>              return SUCCESS;
>        }
>
>        @SkipValidation
>        public String  list() {
>              List l = new ArrayList();
>              l = getCustomerList();
>
>              return "list";
>        }
>
>        public String execute() throws Exception {
>                 return SUCCESS;
>         }
>
> }
>
> I want to disable validation for 'list' method. However, the validation
> still takes effect. The symptom is if there is no input in the form before
> clicking "List" button to execute 'list' method, it will return to 'INPUT"
> result which is not what I want. If there is some input, for example,
> checking a checkbox before clicking the 'List" button, then it will run into
> 'list" method and give a right result.
>
> Obviously, it still try to validate before executing 'list' method even
> there is @SkipValidation annotation. Has anybody come cross the similiar
> problem before? The struts version is 2.0.9.
>
> Thanks!
>
> BC

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