struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sloan Bowman <smil...@nashlinux.com>
Subject Re: Bean in the view or in the model?
Date Wed, 18 Jun 2003 06:59:32 GMT
Andy,
	You never want to have a bean return html tags because this 
would cause the bean to only be used in as a http bean. Instead you 
should create a Data Access Bean pull the data from the database and 
return a State bean to the view you are wanted to use. In the view 
you can use the state bean to get the parameters. For example:

Your query the database using the DAO and return a UserBean Object. 
In the Action set this bean into the session with 
session.setAttribute("userBean", userBean). Then have the Action 
return a ActionForward to the correct  view. Use the view to get the 
information from the Bean to display or in your case create the html 
tags you wanted. Hope this helps

-Sloan

>hi! I am currently learning struts, and I have a bean that I can set
>some parameters, and then it query the database, render and return the
>result as a HTML table.  I am just wondering if I should place this bean
>in the View (the jsp page), or the Model then return the string (HTML
>table) to the JSP page using request for displaying? Would there be a
>better way?
>Please point me to a source for this area of information, thanks.
>
>Andy Cheng
>andy@pos.st
>


-- 
Sloan Bowman
www.nashlinux.com
www.q3networks.com
www.aboutgoodlettsville.com
www.spudibby.com
---------------------------
Windows 95/NT - 32 bit extensions and a graphical shell for a 16 bit 
patch to an 8 bit operating system originally coded for a 4 bit 
microprocessor, written by a 2 bit company that can't stand 1 bit of 
competition.

---------------------------------------------------------------------
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