• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts FormBeans and conventional DataBeans

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[originally posted to JSP forum, but got no response. Since it's being done with WAS Studio 5.0, thought I would try here. (It's also right up Kyle's alley!)]
I have a question that falls between matters of taste and best practicies.
I am new to using Struts in a MVC architecture. I have done a good deal of three-tier programming using DataBeans to pass information between the tiers. One specific practice I use is a so-called "TransportBean" that can hold a vector of DataBeans so that multiple results can be returned from a DBMS search. Each value returned is then likely to be represented as an independent DataBean -- call it an EntryBean or a ResponseBean.
Now, consider a Struts UI that will interface to such an architecture. I don't want to use ActionFormBeans as EntryBeans or Request/ResponseBeans because of having to import the org.apache.struts.action.ActionForm in the EJB container classes and becuase it seems like it shouldn't be sent to the backend, anyway.
Where is the most apporpriate place to map from ActionFormBeans to, say, a set of RequestBean/ResponseBean classes that will be sent to/from the EJB container? It could be done in the Model component, but although FormBeans are not supposed to be bound to a particular UI Form, they do have a strong associaiton with such. It could be done in the generated Action Servlet component. That has the advantage of leaving the Model more general (i.e., not having to know about ActionFormBeans) but requires a mapping in the Control Components. This has the disadvantage of adding more funtion to a component one would like to keep as simple as possible (i.e., focused on the control task) and it will require mapping methods for each such action.
I'd appreciate perspectives and suggestions on this.
thanks.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I dont' know how relevant my answer is to you. But, normally we write Mapper classes in the UI layer (Controller) which maps a business object (your Entity bean?) into a struts Form object. IN this way, Mapper is the one which ties the knot between the Model and the UI (Form bean). THe Action class can call this mapper to map betwwen Form and the business object.
We can discuss further if you feel this is not a best practice..
Lakshmanan
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John!
Glad to see you hanging around the JavaRanch. I actually dealt with this a bit in my Struts intro article but only at a surface level. The idea posted above (use a Mapper object to map from the FormBean to a real domain object) is a common one -- that's probably the best practice.
Hope this helps.
Kyle
[ April 11, 2003: Message edited by: Kyle Brown ]
 
john b. smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, guys, for the help.
Lakshmanan's susggestion for a mapper as part of the control level seems right. Kyle's comments in his introduction to Struts article were also helpful.
Kyle, I think it is time for a Part 3 article for WSAD5.0 since its support for Struts is so different from VisualAge's, and generated Struts seem like they are likely to becocme the preferred way of doing things.
john
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic