The only way which I've done such a thing is with a bean nested one 
level inside another.

The constructor is called on the root bean, and have getters and setters 
there waiting to handle the parameters that you're passing from your 
form. In your action, call another method which will then build the 
nested bean with everything which you need from the database. From then 
in, reference properties in the internal bean via nested properties.

So the sequence happens like this....

1) Form is submitted with parameters needed to load the bean.
2) The constructor is called in the root bean and an empty root bean is 
made.
3) Struts servlet will populate properties with your init parameters.
4) In your action, call a method like "initInternalBean()" or something.
5) Inside this method, access the properties which were set by the form, 
and build an internal bean to what you need..
6) If you have a simple getter method to access the bean you can get to 
the properties you need via nested properties which you can use 
thereafter in your JSP's etc.
eg.  "internalBean.beanProperty"

Is this enough to get across what I'm trying to say?...
I can provide a simple code snippet if it's not.
If you're worried about managing nested objects in your JSP's.... I can 
help there too. ;)


Arron.

Jon Burford wrote:

>Greetings!
>
>I have a dynamic form which needs to be initialized from the database.  If I put code 
>to initialize the attributes in the default constructor of the form bean, all this 
>happens with no problems - the form is displayed with the proper values.  My problem 
>is that the form bean needs some of the request parameters from the calling jsp page 
>in order to properly initialize its fields.  What is the preferred way of form bean 
>initialization and how can it access request parameters at initialization time?  I 
>used a couple hidden form fields which the jsp page initialized to the corresponding 
>request parameters, but this does not take effect until AFTER the constructor is 
>called.  Any help would be much appreciated.
>
>TIA!
>Jon
>
>



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

Reply via email to