Thanks Jeff,

After looking at the solution, I understand fundamentally what is occuring. 
Thanks Jeff.

PS, what is the BeanUtils doing? I am unfamiliar with that. I have been doing 
everything by hand. Could you give me the quick explain of how that may help my 
development time?

I sincerely appreciate all the help,
Scott






-----Original Message-----
From: Jeff Beal [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 17, 2005 8:33 AM
To: Struts Users Mailing List
Subject: Re: create bean in action, and have display in jsp question


When DisplayMyAccount.execute is called, the Struts framework will
already have created an instance of your usersbean and placed it in
the request.  You get this bean as the first argument to the execute
method.

Your codes in DisplayMyAccount.execute could look something like this:

  UserForm uForm = (UserForm)form;
  UserDTO userData = loadUserFromDatabase();
  BeanUtils.copyProperties(uForm, userData);
  return mapping.findForward("Success");

Note that you don't need 'request.setAttribute' -- the framework has
already (or will) handled that.

-- Jeff


On Thu, 17 Mar 2005 08:19:35 -0600, Scott Purcell
<[EMAIL PROTECTED]> wrote:
> Hello,
> 
> Up until today, my workflow has been to give the user a jsp form, user 
> submits, to an action, where a form bean collects and data, validates it, 
> sends it to an action and the cycle is complete. I get this flow and all is 
> good.
> 
> Today, I have a unique problem. I actually have the need to go to the 
> database, populate a bean, and then display the contents of that bean in a 
> jsp page. (Basically backwards from what I have done in the past).
> 
> So here is what I tried to do, but it does not seem to function properly.
> I created an action
>  <action path="/myaccount"
>       type="com.ddi.dealer.action.admin.DisplayMyAccount"
>       name="usersbean"
>       scope="request"
>       validate="false"
>       input="/jsp/admin/mainAdmin.jsp">
>       <forward name="Success" path="/jsp/admin/myAccount.jsp" />
>     </action>
> 
> so when the user calls for myaccount.do,  it tries to create the usersbean. 
> But of course there is no data, so hopefully, it just creates it and puts it 
> into the request scope. Then it goes to the DisplayMyAccount action in which 
> now, I create the usersbean and populate it with data from the database, then 
> I put it into the request scope from the action like so: 
> request.setAttribute("usersbean", usersbean);
> 
> Then I figure it forwards to my jsp page where I have fields like so:
>       <html:text property="firstName" size="30" maxlength="30"/>
> 
> Is what I described the proper way to handle this? And should it work 
> (currently, it is not populating the fields properly)
> 
> I could use some advice if someone has been through this scenario.
> 
> Thanks,
> Scott
> 
> 


-- 
Jeff Beal
Webmedx, Inc.
Pittsburgh, PA USA

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


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

Reply via email to