It's actually better to link only to Actions, and let them forward to a
JSP as needed. 

The Action just returns a forward like 

        return (mapping.findForward("form"));

where you have something like 

        <forward name="form"  path="/WEB-INF/jsp/account/Form.jsp"/>

in your struts-config. 

It's usually convenient to use the same Action for related tasks. For
example, to provide a new input form, the Action may do nothing, and
just return with a blank ActionForm. You can have the same Action do
selects or updates or deletes or whatevers by passing it different
parameters, either as hidden properties or as submit button values, and
then keying on this to do one thing or the other (or forward to another
Action if Perform starts to get too long). 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/


"Hogan, John" wrote:
> 
> Ok, sounds good, but I don't quite understand the case of the update.  How
> is the "visit and Action first" accomplished?  I thought the action followed
> the processing of a form submit/ActionForm processing.  TIA.
> 
> JohnH
> 
> -----Original Message-----
> From: Ted Husted [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 06, 2001 5:44 PM
> To: [EMAIL PROTECTED]
> Subject: Re: ActionForm/Action with edit mode
> 
> If I understand the question, all you have to do is change the form's
> action to insert or update as the case may be. A good way to do this is
> to have a "task" parameter that you would pass to a single action
> designed to handle both cases. You can do this dymamically using (where
> key=0 means we're inserting a new record).
> 
> <logic:equal name="myForm" property="key" value="0">
> <input type="hidden" name="task" value="insert">
> </logic:equal>
> <logic:notEqual name="myForm" property="key" value="0">
> <input type="hidden" name="task" value="update">
> </logic:notEqual>
> 
> For an update, visit an Action first, select the record, populate the
> form, and forward to input.
> 
> John Hogan wrote:
> >
> > All,
> >
> > I have a situation where it is desirable to use a form/page for both
> > adding new info and editing existing data.  The new info scenario is
> > straight forward struts ActionForm/Action classes.  What I'm
> > wrestling with a bit is the edit scenario.  I'm wondering if I can
> > stay within the struts framework and still do something like entering
> > a page in edit mode and have it displaying existing user data?
> >
> > It seems this should be possible because that's exactly what the page
> > does for error handling.  Has anyone else tackled this one yet?  TIA.
> >
> > JohnH
> >
> > _____________________________________
> >
> > Get your free E-mail at http://www.ireland.com
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 737-3463.
> -- http://www.husted.com/about/struts/

Reply via email to