struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riyad Kalla <...@email.arizona.edu>
Subject Re: Multiple action for one (1) form
Date Thu, 29 Apr 2004 18:25:08 GMT
I'm not sure about a 'best way', but do know of what I think is the 'only way' 
to do this :)

Lets take the following situation:
You are writing an admin module that allows you to add a user, edit a user and 
lets say remove a user. That is 3 actions.

Lets say you want 1 form, UserForm, to use with those 3 actions, you define it 
as such:

UserForm:
String name;
String email;
String password;
Date joinDate;

And then you setup your 3 actions in your struts-config:
<action name="userForm" type="AddUser" validate="true" />
<action name="userForm" type="EditUser" validate="true" />
<action name="userForm" type="RemoveUser" validate="false" />

I think the key to sharing forms to knowing when you need to validate and when 
you don't need to. In this example I don't validate in the removeUser action 
because its likely that all the action needs is just 1 field, the user email 
so it can correctly do a SQL query to remove him.

In the other two actions, you are adding a new user and editing/updated the 
users fields, both of which should have the same validation criteria (i.e. no 
empty email address, name must be longer than 1 character... stuff like 
that).

Atlesat this is how I know to do this, does anyone else have a solution?
-Riyad


On Thursday 29 April 2004 11:11 am, Samuel Rochas wrote:
> Hello,
>
> Before struts, I used to handle that with some javascript and hidden
> action wich I evaluated in my servlet.
>
> What is the best way to define different actions for the same form with
> struts?
>
> Thanx
> Samuel
>
> ---  andinasoft SA - Software y Consulting  ---
> Mariano Aguilera 276 y Almagro - Quito, Ecuador
> Tel. +593 2 290 55 18 ---- Cel. +593 9 946 4046
> ---------  http://www.andinasoft.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


Mime
View raw message