Ted and others,

I don't really see the necessity of this extension for your update/insert scenario.

What you want to do is the following:

Insert:                  -> InsertAction
                        /
            ActionForm
                        \
Update:                  -> UpdateAction

Now your problem is, how to specify the right action attribute in ActionForm, right?

Whenever I had a problem like that I did the following:

Insert:   DisplayInsertAction
                                \
                                  -> ActionForm  - >  ProcessAction
                                /
Update:   DisplayUpdateAction

In the actions DisplayInsertAction or DisplayUpdateAction respectively, I store 
a state value in session scope which is checked in ProcessAction and upon with I 
decide whether to do an update or insert.

With this pattern I do not really see the necessity to dynamically set the 
action attribute in forms.

Do I miss something?

--- Matthias



Ted Husted wrote:

> The general idea I'm playing with now is 
> 
> 1) Extend ActionMappings with "request" and "actionPath" properties. 
> 
> 2) Extend ActionServlet to place the ActionMapping in the request
> context if request=true.
> 
> 3) Extend html:form to check for ActionMapping.getActionPath() when the
> path is not specified. 
> 
> So in struts-config you could specify 
> 
> request="true"
> actionPath="/insertAction"
> parameter="insert"
> 
> or 
> 
> request="true"
> actionPath="/updateAction"
> parameter="update"
> 
> and have the appropriate path automagically appear in your html:form.
> The Action can then call getParameter() to determine whether it's
> suppose to insert or update the ActionForm data. Viola, no hidden
> fields!
> 
> 
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 737-3463.
> -- http://www.husted.com/about/struts/
> 
> 
> Chuck Stern wrote:
> 
>>I think this is a great idea.  I can't tell you how many times I've
>>dynamically loaded hidden fields to determine the "nextAction".  A standard
>>way of doing this would be very nice.
>>
>>Chuck
>>



Reply via email to