The pattern I use works as followed:

- create a Action which reads data from a database
- stuff all data in a bean and request.setAttribute("BeanName", bean);
- forward to your "view" jsp and reference your data as <bean:write
name="BeanName" property="field"/>

NOTE:

directly requesting the .jsp will give you an "cannot find bean BeanName"
exception. you may want to add a trap for that or simply moving the .jsp out
of a public folder (to WEB-INF/ for example)

-----Original Message-----
From: Brett G. Palmer [mailto:[EMAIL PROTECTED]]
Sent: vrijdag 20 juli 2001 4:18
To: [EMAIL PROTECTED]
Subject: How do you load information into a bean that your form uses
before displaying it?


I have a struts <html:form> which uses a struts Form bean.  I'd like to read
data from a database and use that data as the default data for the form.

What is the best way to do this?

Read the data and set the value parameter of the <html:text> <html:select>
and <html:checkbox> tags?

Load the data into a Form bean and use that bean for the form?

I'm not sure how to do either of these options or if there is a third better
way to do it?

Thanks,
Brad




Reply via email to