struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eddie Bush <ekb...@swbell.net>
Subject Re: Scope of form beans
Date Sat, 21 Sep 2002 15:32:23 GMT
So you're trying to pre-populate a form?  ... which you're just about to 
show a user?

link -> action f-> JSP  (f-> == forward)

- link points to action
- action populates form
- action forwards control to JSP

Is this your scenario?

You need to:
    - build a form-bean (by extending ActionForm) or use a 
DynaActionForm (or similar)
    - associate the form-bean with the action (so Struts will create it)
    - extend Action (or one of it's descendants) and code the "execute" 
method so that it pre-populates your bean and then forwards to the JSP page.

Once you have done this, your action is passed an instance of the 
form-bean which should be available to the JSP page.  You just populate 
it and forward control.  Be aware though :-) that if you  then send the 
user to a "view" page (to show what their edits were, perhaps), you'll 
have to be looking in the same scope for the form-bean, or you're not 
gonna find it ;-)

Ex:

<action path="/editUser" ... scope="request" ... />
<action path="/viewUser" ... scope="request" ... />

The default scope is session.  If that's where you want the form kept 
you don't have to specify it.

Howard Miller wrote:

>Hi,
>
>I'm a bit confused... so I hope this makes some sense.
>
>I wish to display a form for the user to edit. BUT the form isn't empty 
>it needs to come from a bean that is sitting in an ArrayList. Is there 
>some way to do this directly?
>
>My answer (that doesn't work) is to create a "standalone" bean (of 
>the same type) in the action form that forwards to the page. I've tried 
>this a number of different ways but my form does not see the bean 
>"bean not found etc". I am creating the bean in request scope - is 
>this correct?
>
>Without ranting on any more, what are the "rules" for doing this, 
>assuming its a good idea at all.
>
>Howard
>
>--
>To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
>

-- 
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>


Mime
View raw message