Wendy, You said

And then, from your Action, you would use the code Jack suggested, plus change your method call:

//retrieve the userId from the session [or wherever it is]:
String userId = session.getAttribute("userId");

//call the DAO class to get the list from the database
List myList = myDao.listFormDetail( userId );


Must it be from an Actioon? Does this mean that you can't use that code above from a within a tiles contrloller, specifically the session.getAttribute()?

Jim


From: "Wendy Smoak" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: "Struts Users Mailing List" <user@struts.apache.org>
Subject: Re: Attributes, Parameter or Class
Date: Sun, 9 Jan 2005 09:20:26 -0700

From: "Jim Douglas" <[EMAIL PROTECTED]>
This line gives me a "cannot find symbol variable request"
String userID = request.getParameter("userID");

Re-read Frank's response-- your DAO class does not (and should not) know anything about requests or sessions. You might also want to review the J2EE BluePrints for the DAO Pattern: http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html


Looking back at your original post, I question having a 'FormDetailDAO'. The DAO layer shouldn't care about forms (unless it refers to something in your database, and not the HTML form as I am assuming.)

To fix the problem you first posed, I think you should change the signature of this method:
public List listFormDetail() {
to
public List listFormDetail(String userId) {


This means you'll pass the userId to the DAO class, which won't care where it came from.

And then, from your Action, you would use the code Jack suggested, plus change your method call:

//retrieve the userId from the session [or wherever it is]:
String userId = session.getAttribute("userId");

//call the DAO class to get the list from the database
List myList = myDao.listFormDetail( userId );

HTH,
Wendy Smoak



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




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



Reply via email to