This is how i use value objects.
I have a property in my form called view. It is user written class and
contains all the information that needs to be available in the jsp.
This view object has to be initialized in ur action class before forwarding
to the jsp.
I find this especially useful when there is a lot of information to be
obtained from a database, to be displayed in a jsp. ActionForm contains only
the fields that the user enters/submits in the html form/page and all other
data is embedded in the view class.
lets say u have have a couple of vectors(Containers) to be initialised from
the database for rendering select boxes.
You can store the vectors int the form, or add each vector seperately to the
request object.
By using a view class which contains two vectors as member variables.
you have to create an instance of the view class and call the set methods to
initialize the two vectors in the instance and then set the ActionsForm
"view" attribute with this instance.
Then in ur jsp,get the view instance from the form and the vectors from it
using <bean:define > tag or something similar.
It is bit more work than adding the vector objects directly to the request.
but it has the advantage in that u can easily see which view objects are
used for an Action or JSP just by looking at the form declarations in
struts-config.xml(if u are using dynamic forms)
-Rana.
Sample form declaration using a view attribute.
<form-bean name="newsForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="newsId" initial=" " type="java.lang.String"/>
<form-property name="title" type="java.lang.String"/>
<form-property name="body" type="java.lang.String"/>
<form-property name="view"
type="edu.sc.asg.manager.view.ManagerNewsView"/>
<form-property name="action" type="java.lang.String"/>
</form-bean>
-----Original Message-----
From: Suresh Addagalla
To: [EMAIL PROTECTED]
Sent: 1/8/2003 6:31 AM
Subject: Passing data to presentation objects
Hi,
I have been reading a lot of material on Struts, but I could not get
answer to my question.
What is the recommended strategy (or a design pattern) to pass data to
the view objects (JSPs in my case)?
One reply I got is to use the form-beans associated with the actions to
pass data to the JSPs. I found some situations when this did not work
well (for example, I faced this problem when I am trying to use the same
form-bean for populating data as well as editing/submitting a form).
What are "value objects" and how are they useful in passing data? Can
someone refer me to a good resource on knowing more about this? Any
examples would be highly useful.
Also, is there any sample application I can download and which can be
used as sort of a reference for common tasks required for struts
programming?
Thanks,
Suresh
<<InterScan_Disclaimer.txt>> <<ATT1661353.txt>>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>