You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Hedgpeth <mh...@indemnimed.com> on 2002/02/05 23:04:27 UTC

RE: Beginner questions

Could someone you give me a simple example of a bean being declared in the
Action class that IS NOT an ActionForm and then accessed in the JSP
<bean:write .../> tag?  The ActionForm maintenance seems to be pretty
straight-forward, but I'm dealing with plenty of objects that don't directly
relate to forms (such as summary data) that I would like to pull up in the
Action class and set so the <bean:write .../> can access it (in a report
format).

Thanks,
Michael Hedgpeth

-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Sunday, January 20, 2002 8:47 AM
To: Struts Users Mailing List
Subject: Re: Beginner questions


The Struts bean tags do not require the useBean read tape, and it is
rare for a Struts application to ever need to do this :) 

Struts is designed to encourage architectures based on the MVC paradigm.
Generally, we recommend that all the beans be created and properties set
by an Action object (org.apache.struts.Action) before forwarding control
the presentation page. The page should just be outputing data, and
shouldn't to do any additional processing. That's the Action's job :)

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Building Java web applications with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


Ronan-Yann LORIN wrote:
> 
> Hi all,
> 
> Excuse me if those questions looks stupid, I've seeked the documentation
but
> couldn't find the answer.
> 
> 1) How do I write the following lines with struts:
> <jsp:useBean id="logonForm" class="app.LogonForm" scope="request" />
> <jsp:setProperty name="logonForm" property="*" />
> I tried to create the bean the following way without success:
> <bean:define id="logonForm" type="app.LogonForm" scope="request" />
> and how to set all it's properties from parameters?
> 
> 2) How do I set a bean's property from an other bean property? (something
> like "logonForm.username = argv.utilisateur")
> 
> Thanks in advance for your help
> Ronan-Yann Lorin
> Banque AGF
> Direction des Opérations, Service Informatique
> tél : 01 44 86 27 99
> fax : 0 811 013 002
> mél : lorinr@agf.fr

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Beginner questions

Posted by Ted Husted <hu...@apache.org>.
Just instantiate the bean, place it the request under a known name, and
then use that same name on the other side. 

 ResultBean result = new ResultBean();

// ...

 request.setAttribute("RESULT",result);


<bean:write name="RESULT" property=" ... />


Michael Hedgpeth wrote:
> 
> Could someone you give me a simple example of a bean being declared in the
> Action class that IS NOT an ActionForm and then accessed in the JSP
> <bean:write .../> tag?  The ActionForm maintenance seems to be pretty
> straight-forward, but I'm dealing with plenty of objects that don't directly
> relate to forms (such as summary data) that I would like to pull up in the
> Action class and set so the <bean:write .../> can access it (in a report
> format).
> 
> Thanks,
> Michael Hedgpeth
> 
> -----Original Message-----
> From: Ted Husted [mailto:husted@apache.org]
> Sent: Sunday, January 20, 2002 8:47 AM
> To: Struts Users Mailing List
> Subject: Re: Beginner questions
> 
> The Struts bean tags do not require the useBean read tape, and it is
> rare for a Struts application to ever need to do this :)
> 
> Struts is designed to encourage architectures based on the MVC paradigm.
> Generally, we recommend that all the beans be created and properties set
> by an Action object (org.apache.struts.Action) before forwarding control
> the presentation page. The page should just be outputing data, and
> shouldn't to do any additional processing. That's the Action's job :)
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Building Java web applications with Struts.
> -- Tel +1 585 737-3463.
> -- Web http://www.husted.com/struts/
> 
> Ronan-Yann LORIN wrote:
> >
> > Hi all,
> >
> > Excuse me if those questions looks stupid, I've seeked the documentation
> but
> > couldn't find the answer.
> >
> > 1) How do I write the following lines with struts:
> > <jsp:useBean id="logonForm" class="app.LogonForm" scope="request" />
> > <jsp:setProperty name="logonForm" property="*" />
> > I tried to create the bean the following way without success:
> > <bean:define id="logonForm" type="app.LogonForm" scope="request" />
> > and how to set all it's properties from parameters?
> >
> > 2) How do I set a bean's property from an other bean property? (something
> > like "logonForm.username = argv.utilisateur")
> >
> > Thanks in advance for your help
> > Ronan-Yann Lorin
> > Banque AGF
> > Direction des Opérations, Service Informatique
> > tél : 01 44 86 27 99
> > fax : 0 811 013 002
> > mél : lorinr@agf.fr
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>