struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <Wendy.Sm...@asu.edu>
Subject RE: URGENT: getting a Session Attribute from ActionForm
Date Fri, 21 Nov 2003 16:39:31 GMT
> From: mohan@physics.gmu.edu [mailto:mohan@physics.gmu.edu] 
> My aim is to get a session Attribute called as "userinfo" in 
> the ActionForm.
> In the ActionForm i have  methods called 
> getAddress,getAddress1,getAddress2.
> These are all addresses of this person. So what i want to do 
> is, if all
> the info is already present in the db, i want to pre-populate 
> it.If not
> the user should beable to fill out the form.
> 
> In my getAddress() method i want to do something like this
> 
> public Address getAddress(){
>   Userinfo userinfo = session.getAttribute("userinfo");

IMO, this does not belong in the ActionForm.  It's the right thing to
do, wrong place.  

You do this in the *Action*.  In the execute method, you look in the
session and see if there's a userinfo attribute, if there is, you
populate the form bean and then forward to the JSP.

The ActionForm is just a container, it should not "know" about the
session or the Action.

-- 
Wendy Smoak
Application Systems Analyst, Sr.
ASU IA Information Resources Management 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message