You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Melissa Rabin <ed...@jamethial.ath.cx> on 2001/07/19 22:50:07 UTC

Getting session objects in an Action Form

I need to access a session object within an ActionForm class - is this
possible, & how?


Melissa Rabin
Web Developer


PLEASE UNSUBSCRIBE

Posted by Billy Talton <bt...@digdatdesign.com>.
I tried via list server email address last week but apparently it does
not work!

-----Original Message-----
From: Renzo Toma [mailto:renzo.toma@xs4all.nl] 
Sent: Friday, July 20, 2001 6:13 AM
To: struts-user@jakarta.apache.org; suhas
Subject: RE: How do you load information into a bean that your form uses
before displaying it?


Not when you dont have a Form for your Action, which in my case ;)
Maybe I do not understand the question; you are referring to a normale
Form-Action-JSP model. Maybe Brett is too!?



-----Original Message-----
From: suhas [mailto:suhas_k@techmas.hcltech.com]
Sent: vrijdag 20 juli 2001 17:36
To: struts-user@jakarta.apache.org
Subject: Re: How do you load information into a bean that your form uses
before displaying it?


no need to put the form Bean using the request.setAttribute("beanname",
bean) . It is done by struts framework .
rest is fine . Use <html:form> tag in Jsp .

Suhas

----- Original Message -----
From: Renzo Toma <re...@xs4all.nl>
To: <st...@jakarta.apache.org>
Sent: Friday, July 20, 2001 11:46 AM
Subject: RE: How do you load information into a bean that your form uses
before displaying it?


>
> 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:pbganjanette@qwest.net]
> Sent: vrijdag 20 juli 2001 4:18
> To: struts-user@jakarta.apache.org
> 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
>
>
>




RE: How do you load information into a bean that your form uses before displaying it?

Posted by Renzo Toma <re...@xs4all.nl>.
Not when you dont have a Form for your Action, which in my case ;)
Maybe I do not understand the question; you are referring to a normale
Form-Action-JSP model. Maybe Brett is too!?



-----Original Message-----
From: suhas [mailto:suhas_k@techmas.hcltech.com]
Sent: vrijdag 20 juli 2001 17:36
To: struts-user@jakarta.apache.org
Subject: Re: How do you load information into a bean that your form uses
before displaying it?


no need to put the form Bean using the request.setAttribute("beanname",
bean) . It is done by struts framework .
rest is fine . Use <html:form> tag in Jsp .

Suhas

----- Original Message -----
From: Renzo Toma <re...@xs4all.nl>
To: <st...@jakarta.apache.org>
Sent: Friday, July 20, 2001 11:46 AM
Subject: RE: How do you load information into a bean that your form uses
before displaying it?


>
> 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:pbganjanette@qwest.net]
> Sent: vrijdag 20 juli 2001 4:18
> To: struts-user@jakarta.apache.org
> 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
>
>
>



Re: How do you load information into a bean that your form uses before displaying it?

Posted by suhas <su...@techmas.hcltech.com>.
no need to put the form Bean using the request.setAttribute("beanname",
bean) . It is done by struts framework .
rest is fine . Use <html:form> tag in Jsp .

Suhas

----- Original Message -----
From: Renzo Toma <re...@xs4all.nl>
To: <st...@jakarta.apache.org>
Sent: Friday, July 20, 2001 11:46 AM
Subject: RE: How do you load information into a bean that your form uses
before displaying it?


>
> 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:pbganjanette@qwest.net]
> Sent: vrijdag 20 juli 2001 4:18
> To: struts-user@jakarta.apache.org
> 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
>
>
>


RE: How do you load information into a bean that your form uses before displaying it?

Posted by Renzo Toma <re...@xs4all.nl>.
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:pbganjanette@qwest.net]
Sent: vrijdag 20 juli 2001 4:18
To: struts-user@jakarta.apache.org
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





How do you load information into a bean that your form uses before displaying it?

Posted by "Brett G. Palmer" <pb...@qwest.net>.
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




Re: Getting session objects in an Action Form

Posted by Peter Alfors <pe...@irista.com>.
You can access the session through the HttpServletRequest:

Object myObject = request.getSession().getAttribute("myKey");

HTH,
    Pete

Melissa Rabin wrote:

> I need to access a session object within an ActionForm class - is this
> possible, & how?
>
> Melissa Rabin
> Web Developer