struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
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 <> 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
> 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:

[2] Default S2 config defining "validation"'s skipped methods:

[3] Preparable interface:

[4] "prepare" interceptor:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message