Hello Jon,
Thursday, December 13, 2001, 7:40:34 AM, you wrote:
JB> Greetings!
JB> I have a dynamic form which needs to be initialized from the
JB> database. If I put code to initialize the attributes in the
JB> default constructor of the form bean, all this happens with no
JB> problems -
JB> the form is displayed with the proper values. My problem is that
JB> the form bean needs some of the request parameters from the
JB> calling jsp page in order to properly initialize its fields. What
JB> is
JB> the preferred way of form bean initialization and how can it
JB> access request parameters at initialization time? I used a couple
JB> hidden form fields which the jsp page initialized to the
JB> corresponding request parameters, but this does not take effect
JB> until AFTER the constructor is called. Any help would be much
JB> appreciated.
Firstly - place such questions to the struts-user list, please.
Common solution to fill form with values from database is to create
Action class and appropriate mapping for it -
public class ReadAction extends Action {
... some stuff to read values from database, create or retrieve
ActionForm bean, fill it with values and store this bean in
request or session. Return 'success' forward if all is ok and
'error' if any errors.
}
and map this class to the read.do path, for example.
<action path="/read"
type="org.somepackage.ReadAction"
attribute="someForm"
scope="request"
validate="false">
<forward name="success" path="/viewValues.jsp"/>
<forward name="error" path="/error.jsp"/>
</action>
viewValues.jsp form contains form 'someForm'.
--
Best regards,
Oleg mailto:[EMAIL PROTECTED]
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>