There's any number of ways you could accomplish this, but I like to
think in terms of the simplest. Here's my suggestion...
Instead of using a ForwardAction, use a real Action. In it, get the
reference to the form (which is of course passed in to execute()
automaticly), populate it, and your done.
I'd say that is a more or less "typical Struts" way of doing it.
Whether it's the recommended way or not I'm not sure, but I don't see
anything inherently wrong with it.
To keep proper seperation of layers you'd probably want to call a
business delegate (nothing more than a class that knows how to get the
data you require on the edit screen), return a POJO from it with fields
matching those in the ActionForm you want to pre-populate, and use
BeanUtils to copy the POJO's data to the ActionForm. This of course
makes it a bit more complex, but is generally better architecturally.
Frank
Tony Dahbura wrote:
There is no way I could find to populate the editUserForm bean prior to
it being called from the forwardAction.
Note below in my struts config have a url to viewedituser.do which
invokes the action below. This action needs to setup to display the
form for the user to edit values. How do I get the values into the
action form editUserForm?
<action path="/viewedituser"
parameter="/edituser.jsp"
type="org.apache.struts.actions.ForwardAction"
scope="request" name="editUserForm"
validate="false" >
</action>
After the form is display with the current data to be edited it goes
into this action when the user clicks submit to save the data or cancel
to abort:
<!-- the following handles the action editing of a user record -->
<action path="/edituser"
type="myprogram.actions.EditUserAction"
name="editUserForm"
scope="request"
validate="true"
input="/edituser.jsp" >
<forward name="success" path="/mainpage.do"/>
<forward name="failure" path="/edituser.jsp"/>
<forward name="cancel" path="/mainpage.do"/>
</action>
So my question is still where am I or how am I supposed to get the data
into the editUserForm so it can be displayed for editing in the first
action? None of this is hard if the page is always coming up blank for
say an add....but prefilling it where I am struggling.
Thanks again for any insight-I do not want to start
down a road that is wrong with the struts way,
Tony
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]