an issue with my Action class - help me
Hi, I am new to struts 2. my page is having a list which is dynamically generated by action, so while calling the jsp page itself from a menu, I am calling URL /mymodule1/EditEmployee.action, which is mapped to EditEmplyeeAction.java. first time when i am generating the page I am generating list values dynamically and returning *ActionSupport.INPUT*, if Save button is clicked on my page i am again going to the EditEmployeeAction and this time i am doing my process and returning *ActionSupport.SUCCESS*. but here the problem is, i have validation annotations implemented for all the fields, which are executed and reporting error messages when i am loading the page for the first time itself. but it should not happen to my page, first time it should be executed with out validations, and when save button is clicked only it should check for validations... to achieve this do i need to go for CRUD kind of approach? or any other simple way is there?
Re: an issue with my Action class - help me
Hi, I'm supposing that you have actions mapped by methods in action class (execute(), update(), etc.) If so, to disable validation for particularly methods, annotated them with @SkipValidation Regards -- Lukasz http://www.lenart.org.pl/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: an issue with my Action class - help me
--- On Tue, 7/15/08, Narayana S [EMAIL PROTECTED] wrote: I am new to struts 2. my page is having a list which is dynamically generated by action, so while calling the jsp page itself from a menu, I am calling URL /mymodule1/EditEmployee.action, which is mapped to EditEmplyeeAction.java. first time when i am generating the page I am generating list values dynamically and returning *ActionSupport.INPUT*, if Save button is clicked on my page i am again going to the EditEmployeeAction and this time i am doing my process and returning *ActionSupport.SUCCESS*. but here the problem is, i have validation annotations implemented for all the fields, which are executed and reporting error messages when i am loading the page for the first time itself. but it should not happen to my page, first time it should be executed with out validations, and when save button is clicked only it should check for validations... In addition to the information provided by Lukasz I'd add that typically this would be handled by (a) separate actions, or (b) by using the input() and execute() methods in a single action, accessed via separate action configurations (or dynamic method invocation if enabled). Note that ActionSupport provides a default input() method that returns ActionSupport.INPUT, meaning (a) you write less code, and (b) the code you write is focused on a single task, rather than implementing a conditional that can be handled automatically by the framework. An action's input() method will skip validation by default ([1], [2]). The list values may be created in either both input() and execute() methods, or perhaps more cleanly by implementing the Prepareable interface [3] used by the prepare interceptor [4]. Dave Too much information Newton [1] validation interceptor: http://struts.apache.org/2.x/docs/validation-interceptor.html [2] Default S2 config defining validation's skipped methods: http://struts.apache.org/2.x/docs/struts-defaultxml.html [3] Preparable interface: http://struts.apache.org/2.1.2/struts2-core/apidocs/index.html [4] prepare interceptor: http://struts.apache.org/2.x/docs/prepare-interceptor.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: an issue with my Action class - help me
Thanks Dave and Lukasz, i got the concept, and solved the issue. Thank you very much. On Tue, Jul 15, 2008 at 4:47 PM, Dave Newton [EMAIL PROTECTED] wrote: --- On Tue, 7/15/08, Narayana S [EMAIL PROTECTED] wrote: I am new to struts 2. my page is having a list which is dynamically generated by action, so while calling the jsp page itself from a menu, I am calling URL /mymodule1/EditEmployee.action, which is mapped to EditEmplyeeAction.java. first time when i am generating the page I am generating list values dynamically and returning *ActionSupport.INPUT*, if Save button is clicked on my page i am again going to the EditEmployeeAction and this time i am doing my process and returning *ActionSupport.SUCCESS*. but here the problem is, i have validation annotations implemented for all the fields, which are executed and reporting error messages when i am loading the page for the first time itself. but it should not happen to my page, first time it should be executed with out validations, and when save button is clicked only it should check for validations... In addition to the information provided by Lukasz I'd add that typically this would be handled by (a) separate actions, or (b) by using the input() and execute() methods in a single action, accessed via separate action configurations (or dynamic method invocation if enabled). Note that ActionSupport provides a default input() method that returns ActionSupport.INPUT, meaning (a) you write less code, and (b) the code you write is focused on a single task, rather than implementing a conditional that can be handled automatically by the framework. An action's input() method will skip validation by default ([1], [2]). The list values may be created in either both input() and execute() methods, or perhaps more cleanly by implementing the Prepareable interface [3] used by the prepare interceptor [4]. Dave Too much information Newton [1] validation interceptor: http://struts.apache.org/2.x/docs/validation-interceptor.html [2] Default S2 config defining validation's skipped methods: http://struts.apache.org/2.x/docs/struts-defaultxml.html [3] Preparable interface: http://struts.apache.org/2.1.2/struts2-core/apidocs/index.html [4] prepare interceptor: http://struts.apache.org/2.x/docs/prepare-interceptor.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]