The way this is typically handled is to use an Action to populate the 
bean.  So instead of linking your user directly to the JSP page, you link 
them to an Action.  This Action typically loads the bean and then returns 
the success mapping, which, in struts-config.xml, you've mapped to the JSP 
that displays the values from the bean.

The example application that comes with struts shows how to do this.  The 
walking tour that accompanies the example explains it better than I 
have.  Look at the relationship between EditSubscriptionAction.java, 
subscription.jsp, and SaveSubscriptionAction.java.


Mike

At 11:46 AM 2/27/2001, you wrote:
>Hi all,
>
>I am working on an application where form fields need to default to
>values that depend on the user's profile, which is stored in the
>session.  Unfortunately, it seems like struts forms are created
>automatically without any hooks that allow access to the session to
>initialize these fields.
>
>The only thing that I can think of is to have our application
>proactively place the forms into the session with values initialized,
>possibly to have the form page link through an action which creates and
>initializes the form.  However this abandons the utility of having
>struts automatically create the forms for us - one of the many nice
>things about struts!
>
>This seems to me like it would be a common problem.  Does anyone have a
>good solution for it?
>
>Cheers,
>
>Simon.

Reply via email to