You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cristiano Monteiro dos Santos <cr...@atech.br> on 2003/08/05 22:29:34 UTC

Retriving data from model to view

Hi there, guys!

I'm new at Struts and I have a doublt about how to retrieve data from a database using the Action classes to send them back to the view layer. I have read that it's a bad idea to mix form-beans with the model elements and that I'm supposed to take data from those form-beans, populate an entity and them pass this entity to my business layer.

Is this thougth valid in the way back? Am I supposed to send back to my jsp's only form-beans or I can send entitys directly from my model?

TIA!
-CMS

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


Re: Retriving data from model to view

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
You can send "entities" and in fact the nested-plugin is built to deal 
with beans nested within beans within the form-bean (or in any scope 
perhaps, I'm not sure).

I guess that is the trade-off. If you have only one object, then 
transfer it to the form-bean, following best practices, i.e. the 
form-bean properties are all Strings.

If you have nested objects, pass them along as is, and use the nested 
taglibs. In a project I did using nested taglib, I passed objects via 
the form-bean to the JSPs. The objects had all their normal typed 
properties, but non-String properties also had corresponding string 
properties that accessed and converted the normal-typed props internally.

hth
Adam

Cristiano Monteiro dos Santos wrote:
> Hi there, guys!
> 
> I'm new at Struts and I have a doublt about how to retrieve data from a database using the Action classes to send them back to the view layer. I have read that it's a bad idea to mix form-beans with the model elements and that I'm supposed to take data from those form-beans, populate an entity and them pass this entity to my business layer.
> 
> Is this thougth valid in the way back? Am I supposed to send back to my jsp's only form-beans or I can send entitys directly from my model?
> 
> TIA!
> -CMS
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


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