You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sougata <so...@tpgsi.com> on 2004/06/21 08:04:24 UTC

where to call the DAO

Hi All
I am working with struts framework.I have a JSP page (index,jsp) here I am
population a Dropdown from database.Where to populate the driopdown.Actually
my DAO class is returning a List of dropdown values.In JSP shall I call the
DAO class.But I am sure this will be a bad practise.Can anyone help
Sougata


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


Re: where to call the DAO

Posted by Rick Reumann <st...@reumann.net>.
javen fang wrote:

> In your Action where JSP comes from. 
> 
> In Action get the list from DAO,  

I usually throw in one more layer between the Action and the DAO. (Throw 
whatever groovy Design Pattern name you want at it.. delegate, facade, 
whatever.. I get them all confused :). Bottom line is I like to call 
something from the action like...

List list myDelegate.getWhateverList();

myDelegate.updateSomething( Something VO );

Then the myDelegate object can call the DAO. I do this in case there are 
other business related things I need to also do before or after the 
actual DAO call. Some exmaples:

Maybe you want a factory to return the correct DAO. Seems more 
appropriate to abstract this out away from the Action.

Maybe after you do an update some other business rules need to take 
place... e-mail someone, make some other kind of update to a different 
table, etc. The Action really should be "Dumb" to all this so it makes 
sense to do this in another layer.

For a simple app calling the C.R.U.D stuff (create, retreive, update, 
delete) from a DAO in your action isn't that bad though. I just happen 
to like the one extra layer.

-- 
Rick

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


Re: where to call the DAO

Posted by javen fang <fa...@yahoo.com.cn>.
In your Action where JSP comes from. 

In Action get the list from DAO, and
request.setAttribute, and in the JSP use
<html:options..>

--- sougata <so...@tpgsi.com> wrote:
> Hi All
> I am working with struts framework.I have a JSP page
> (index,jsp) here I am
> population a Dropdown from database.Where to
> populate the driopdown.Actually
> my DAO class is returning a List of dropdown
> values.In JSP shall I call the
> DAO class.But I am sure this will be a bad
> practise.Can anyone help
> Sougata
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail

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