Hi,

In your example, Struts knows about the implementing class for the
form-property bean (ManagerNewsView). Is it necessary and how can we
avoid?

<form-bean name="newsForm"
type="org.apache.struts.validator.DynaValidatorForm">
        <form-property name="view"
type="edu.sc.asg.manager.view.ManagerNewsView"/>
</form-bean>

Thanks,
Suresh

>-----Original Message-----
>From: VEDRE, RANAPRATAP REDDY [mailto:[EMAIL PROTECTED]] 
>Sent: Wednesday, January 08, 2003 6:43 PM
>To: 'Suresh Addagalla '; '[EMAIL PROTECTED] '
>Subject: RE: Passing data to presentation objects
>
>
> 
> 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

**************************Disclaimer************************************************** 
   
 
 Information contained in this E-MAIL being proprietary to Wipro Limited is 
'privileged' 
and 'confidential' and intended for use only by the individual or entity to which it 
is 
addressed. You are notified that any use, copying or dissemination of the information 
contained in the E-MAIL in any manner whatsoever is strictly prohibited.

****************************************************************************************




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

Reply via email to