struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <newton.d...@yahoo.com>
Subject Re: an issue with my Action class - help me
Date Tue, 15 Jul 2008 11:17:30 GMT
--- On Tue, 7/15/08, Narayana S <narayanasgs1@gmail.com> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message