struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Taylor" <rtay...@mulework.com>
Subject RE: Pre-populating Form Bean
Date Fri, 20 Dec 2002 19:55:55 GMT
Don't validate the pre edit Action. This should allow your form to propogate
to the Action.execute() where you can populate the form. Make sure you are
forwarding to the destination page and not redirecting.
Your almost there, don't give up yet. So set validate="false" in the struts
config file for the pre edit action mapping.

robert

> -----Original Message-----
> From: Mark Conlin [mailto:meconlin@yahoo.com]
> Sent: Friday, December 20, 2002 2:30 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Pre-populating Form Bean
>
>
>
>
> Okay, I think I am missing something major here.
> By watching the log files I see the following.
>
> 1)Proccessing my pre edit Action -
> "customer.customAccountDetails.pre.edit"
> 2)Struts then looks for my ActionForm -  "customerDetailsForm"
> 3)Struts then creates my ActionForm since it can not find it.
> 4)The form fails validation, as described by my validation.xml file.
>
> The pre edit Action never runs...
>
> The result is that I arrive at my "create" page with validation errors
> because the validation logic tells it to return to that page.
>
> So, how can I pre-populate a Form? What am I don't wrong here...
>
> Mark
>
>
> -----Original Message-----
> From: Mark Conlin [mailto:meconlin@yahoo.com]
> Sent: Friday, December 20, 2002 1:38 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Pre-populating Form Bean
>
>
> Okay so I have done the following...
> I placed name="customerDetailsForm" into my action declaration..
> It wanted an input field as well so I added that too.
>
> Now my form comes up and it is still not populated...
>
> My action execute code is below... are you sure I don't need to place
> the custForm back into the session somehow ?
>
>
> Thanks
> Mark
>
> logger.debug("performAction starting");
> ActionErrors errors 			= new ActionErrors();
> ActionForward actionForward 	= mapping.findForward(FAILURE);
> CustomerDetailsForm custForm 	= (CustomerDetailsForm) form;
> HttpSession session = (HttpSession) request.getSession();
>
> custForm = this.setup( session );
> actionForward = mapping.findForward(SUCCESS);
>
> logger.debug("performAction exiting");
>
> Action Declaration:
>
> <action path="/customer.customerAccountDetails.edit"
> type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
> 	name="customerDetailsForm"
> 	scope="session"
> 	input="customer.account_details_view">
> <forward name="success"
> path="/customer.customerAccountDetails.view.do"/>
> <forward name="failure" path="customer.edit_accountdetails"/>
> </action>
>
>
> -----Original Message-----
> From: Eddie Bush [mailto:ekbush@swbell.net]
> Sent: Friday, December 20, 2002 2:13 PM
> To: Struts Users Mailing List
> Subject: Re: Pre-populating Form Bean
>
> If this is a form which you've declared in your config file, and it's
> associated with this action and you're forwarding to a JSP, you really
> needn't bother sticking it into any scope.  Struts will do this for you.
>
>  Just populate the form and return an ActionForward and let Struts do
> it's thing.
>
> ... so far as your error is concerned, I can't imagine why you're
> receiving it.  You did specify a 'name="formName"' as an attribute to
> this action, right?  That's how you make the association between the
> action and the form.  I believe this value would probably be null if you
>
> didn't specify that attribute - and I can see where that would generate
> an error.
>
> Ah - yes.  I see your action declaration now.  Add in
> 'name="customerDetailsForm"' to your <action line.  That will build the
> association for you.  Once you've done this, you no longer have to worry
>
> about creating the form ... or anything like that - and it's the *only*
> way you're going to get Struts to populate the form for you
> automatically (why would it populate something if it doesn't know there
> is something to populate?).
>
> Good luck!
>
> Mark Conlin wrote:
>
> >
> >I would like to pre-populate a form bean for an edit screen.
> >I have spent the last hour or two reading the archives and still I have
> >failed to find the help I need.
> >Any feedback would be appreciated.
> >
> >I have an Action class CustomerAccountDetailsPreEditAction that
> >pre-populates my form.
> >However, I do not know how to place the form back into the session or
> >request so that the jsp page can find it and use it to display values.
> >
> >request.setAttribute(mapping.getName(), myForm);
> >session.setAttribute(mapping.getName(), myForm);
> >
> >Both result in an error.
> >
> >Here is the action declaration:
> >            <action path="/customer.customerAccountDetails.pre.edit"
> >
> >type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
> >                        <forward name="success"
> >path="customer.edit_accountdetails"/>
> >            </action>
> >
> >
> >Here is the form declaration:
> ><form-bean name="customerDetailsForm"
> >type="com.yordata.form.CustomerDetailsForm"/>
> >
> >
> >Thanks for your help,
> >Mark
> >
> >
> >
>
> --
> Eddie Bush
>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>


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


Mime
View raw message