struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michal Maczka" <mmac...@interia.pl>
Subject RE: Reusing the same HTML Form for many actions
Date Tue, 03 Jun 2003 20:39:29 GMT


> -----Original Message-----
> From: Bailey, Shane C. [mailto:SHANE.C.BAILEY@saic.com]
> Sent: Tuesday, June 03, 2003 10:10 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Reusing the same HTML Form for many actions
>
>
>
> I don't agree that these things are two COMPLETELY different
> things.  Adding
> a User and editing a Group might be two completely different things but in
> the one case a adding a User and editing a User are very similar.  Passing
> almost the same field value pairs to the middle tier to do something with
> them.
>
> Then DispatchAction never has a place to exist if all things exactly the
> same must be in an action.
>
> Anyway, so thought you were doing something more complicated because the
> answer then is simple:
>
>  struts config:
>      <action    path="/addUser"
> 	    type="my.web.action.AddUserAction"
>  	    name="userForm"
>  	    input="doc.userForm"
> 	    scope="request">
>  	    <forward name="showUserForm"  path="doc.userForm"/>
>  	    <forward name="showConfirm"  path="doc.addUserConfirm"/>
>      </action>
>
>      <action    path="/editUser"
> 	    type="my.web.action.UpdateUserAction"
>           name="userForm"
>  	    input="doc.userForm"
> 	    scope="request">
>  	    <forward name="showUserForm"  path="doc.userForm"/>
>  	    <forward name="showConfirm"  path="doc.updateUserConfirm"/>
>      </action>
>
> Now both actions are using the same form and same JSP (or definition).
>
> Well then you say, "My validation is slightly different between
> the two" or
> something like that I suppose.
>
> Then make sure your actions extend ValidatorActionForm so that
> you can base
> your validation for the userForm per action name coming in.
>
> validation.xml:
>
> <form name="/addUser">
>  <!-- do validation one way for this action but same form ->
> </form>
> <form name="/editUser">
>  <!-- do validation one way for this action but same form ->
> </form>
>
>
> Am I missing something here?
>
Yes.

It's not a problem of configuration of Struts.
It is purly a problem of using this "shared form" in my JSP pages.

How to write JSP code snippet which will let me conditinally choose
which action I want to use?

I preferably would like to use form (again just in the measing of JSP code)
as a tile.
So I can just  do:
<html:form action="<tiles:getAsString name="action"/>" focus="name"
onsubmit="return validateCustomerForm(this)">


and then in my first jsp page:

 <tiles:insert definition="@forms.user" flush="false" >
      <tiles:put name="action" value ="/user/add"/>
 </tiles:insert>

and in my second jsp page:

 <tiles:insert definition="@forms.user" flush="false" >
      <tiles:put name="action" value ="/user/edit"/>
 </tiles:insert>


etc..


Unfortunately this syntax does not seems to work...

I am not 100% sure if tiles are appropriate for this task.
So I am asking what is the /best practice/guide line/ for
implementing such thing?


Michal








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


Mime
View raw message