Alex,
     I am new to Struts and wish clean answer as well. Our app uses the same
approach as your self.
As part of your question, I assume you trying to avoid what I had to do in my
LoadAction.

In have my app I many "master detail" pages.  So upon a new page I have to set
up the for a new record or populate it with the selected list Item.
In order to use the validation mechanism, I had to look at the errors tag in the
action and not pre-populate the way I otherwise would.

 //This will check if any outstanding error occured from an update
        boolean updateError;
        ActionErrors updateErrors =
(ActionErrors)request.getAttribute(this.ERROR_KEY);
        if((updateErrors == null) || (updateErrors.size() == 0)){
            updateError = false;
        }else{
           servlet.log("Outstanding Update errors size: "+ updateErrors.size());
           updateError = true;
        }

Then user updateError later on.

Don't really like it.  I wonder if the new Validator can help here.

my 1 cent





Alex Paransky <[EMAIL PROTECTED]> on 03/19/2002 12:03:40 PM

Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]>

To:   Struts Users Mailing List <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
cc:

Subject:  RE: How to properly map actions for form edit and save functions?


Ted,

Assuming I use scope="request", and have to actions LoadForm.do and
SaveForm.do.  If then, I configure the input of SaveForm.do to be
LoadForm.do, wouldn't user's input be erased if LoadForm.do gets called in
case of an error?  In my development, a Form contains all the components
necessary to render the .jsp view.  In other words, it contains the
necessary information to display all the options, not just the selected
option.  The LoadForm.do loads the form "completely".  So if it's used on
the input="" parameter, the user's input might get lost in case of an error.

Am I missing something?  I am just looking for a pattern that would allow me
to write less code and repeat of all types for Form/Action interactions.

-AP_
http://www.alexparansky.com
Java/J2EE Architect/Consultant
http://www.myprofiles.com/member/view.do?profileId=127

-----Original Message-----
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 19, 2002 8:19 AM
To: Struts Users Mailing List
Subject: Re: How to properly map actions for form edit and save
functions?


The input property can refer directly to the page, if it doesn't need
any "helper" beans in the request to populate drop-down boxes and such.

When the form is submitted, the elements of the form are made part of
the request, and Struts sucks these into an ActionForm for you. But if
the FormLoad is providing objects or data that do not come from the HTMl
form, you would have to go back through an Action to create them again.

The cleanest thing is to link input to an action-mapping rather than a
page.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


Alex Paransky wrote:
>
> I have a Form and two actions FormLoad.do and FormSave.do.  Both of these
> actions have scope set to "request".
>
> The FormLoad.do initializes the form with data by configuring various
> collections (later used for options on the view), it is set to
> validate="false".
>
> The FormSave.do attempts to save the data entered by the user into the
> database.  It is set to validate="true".
>
> At this point, should the input parameter of the FormSave.do action
> reference the .jsp page (view) or the FormLoad.do action?  If I reference
> the .jsp page directly, the data needed by .jsp is not in the form for
> display (since the new form bean was never loaded for a new request).  On
> the other hand, if I reference FormLoad.do, the data is loaded, but would
> user's input be saved in case of an error?  Should I change the scope of
the
> FormLoad.do and FormSave.do to session and have the input point to .jsp
> page?  If so, when should I remove (cleanup) the bean from the session?
At
> the end of the successful FormSave.do?  What if the user never presses the
> submit button and just leaves the form?  Should the FormLoad.do, then also
> try to remove any existing form beans from the session?
>
> Do you put your form beans in the session or request?
>
> I am looking for a "clean" pattern that I can use across all my Forms.
> Currently, there is no set standard that I use for this type of
interaction.
>
> Thanks.
>
> -------------
> -AP_
> See my profile at
> http://www.myprofiles.com/member/view.do?profileId=128
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>








--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to