wood burning stoves 2.0*
The moose likes Struts and the fly likes FormBeans   X    Business Tier Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "FormBeans   X    Business Tier Beans" Watch "FormBeans   X    Business Tier Beans" New topic
Author

FormBeans X Business Tier Beans

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi.

I�d like to know what�s the best way to interchance data between FormBeans and Business Tier Beans. Is there some kind of �best practice� for doing this ?
Dividing into specific questions :
1) After posting a webpage, Struts automatically populates the FormBean and puts it in the session context, right ? So , supposing I want to persist this data , in the ActionForm I transfer it to the business tier bean through the BeanUtils.populate(BusinessTierBean,FormBean) and then save it... update it... whatever... Right ? Is that the best (if not the only) way of doing this ?
2) And what about the back trip ? From the B.T. bean to the FormBean ? On the way back to the database, do I populate the FormBean from B.T bean the same way , using BeanUtils.populate() ? Is it possible and the best practice ?
3) I�ve wondered if it would be a good idea to create an �hybrid� bean , mixing the two beans up ... once attributes and methods getters and setters are common... Although it has a clear impact in coupling/decoupling tiers..would it be a good idea ?
Well, that�s it !
Thanx .
F�bio
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi there,
I typically create a business delegate and assign it the responsibility of:
1. Creating a value object from information present in the request object.
2. Locating the appropriate session facade.
3. Passing the value object to a Session Facade.
4. Retrieving the resulting value objects returned from the session facade.
5. Using the contents of the resulting value object to populate the request and other objects if necessary.
Hope this helps.
Darryl
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks Darryl !
In fact , I�m an absolute beginner concerning Design Patterns... and... in addition to it , I�m not using EJB at this very moment... So, do you have good references for a good step-by-step learning process on this subject ? Something related to Design Patterns applied to simple Web-Centric applications (no EJBs) ... up to the complete stuff... with Servlets and EJBs... ?
Right now, all I want to do is create a basic navigation including most of the importants concepts to be used in my next project. Like... applying Intercepting Filters and DAO under a web-based Struts application... and some other important Design Patterns to improve the robustness and flexibility of the application...
Thanks again !
F�bio
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi there,
I like Wrox's recept book on Applying Design Patterns with J2EE (NB: Sorry I can't remember the exact title as my book is at work.) If you want to buy it though you'd better get it quickly as Wrox is no more and the what's on the bookshelves is all there is.
You can check out the Sun website for documentation on J2EE design patterns. There is lots of stuff on there.
Darryl
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: FormBeans X Business Tier Beans
 
Similar Threads
Strict separation of tiers
How to connect Servlets and EJBs
Populating the FormBean/Business Tier Bean - doubt on Introspection/Reflection
Using DAO in struts
How to connect Servlets and EJBs