This is the approach that I am using, but to simplify the design I have
interconnected the view and model. I would like to eliminate this coupling-
so if anyone has some suggestions or could recommend a pattern I could apply
please let me know :) What I am doing is creating entity beans that resemble
the ActionForm as much as possible- for the most part there is a loose 1 to
1 relationship between entity EJB and ActionForm. There are some exceptions,
but this is how 80% of the app is designed. I use session EJBs to manage the
entity EJBs and map these to appropriate ActionForms (using the Struts
copyProperties util). So, the session EJB must be aware of the ActionForm,
since this is the object that it returns. To persist data, the ActionServlet
obtains a reference to the session EJB and would send a save() method I have
implemented the ActionForm which then is copied to an entity EJB. Ideally
there should be a proxy between the EJB tier and the Struts tier, so the
session EJB does not need to be aware of the ActionForm. But, I am not about
to create another intermediate object with the same properties and
setters/getters. Some of my forms have up to 30 properties so this is way
too much work! I think this should be done automatically.

One more thing- the copyProperties requires that properties are the same
type. But, the view is basically just String-based where the ejb tier
consists of real Date, BigDecimal, etc... So what I find myself doing is
creating additional methods in the ActionForm that make this transformation.
For example setCustomerId(BigDecimal) and setCustomerIdStr(String). Then use
the string version for Struts, and when copyProperties is invoked it will
map the BigDecimal value to the EJB. Perhaps I should extend copyProperties
to support basic type conversions- or has this already been done elsewhere?

thoughts or suggestions?

Thanks,
Bob


-----Original Message-----
From: Nick Pellow [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 27, 2001 5:23 PM
To: [EMAIL PROTECTED]
Subject: Re: Stupd question about Struts and EJB.



Hello, 

Robert Leland wrote:
> 
> As far as struts 1.0, the Form bean is used only to redisplay
> information to the jsp page. Typically the EJB might be loaded/unloaded in
the
> action class. If you search www.mail-archives.co,m Craig talked more about
this in detail.

My understanding is that with struts you should keep your EJBs entirely
independant of
anything to do with struts or servlets. You can and should however have
a standard naming
convention for the getters and setters across the EJB, the ActionForm
and the html form elements.
this allows you to call PropertyUtils.copyProperties(java.lang.Object
dest, java.lang.Object orig)
when you are ready to store the details entered by the user.

Please let me know if this does not sound right.

Cheers, 
Nick

> In future version of struts this may be enhanced.
> 
> -Rob
> 
> > Cameron Ingram0 wrote:
> >
> > I am in the process of convincing my company to go with MVC and Struts.
As with any thing new,
> > people are sometimes resistant
> > to change. One of the opposition questions I am getting is, how will
this work with EJB(problem is
> > I don't know too much about EJB currently).  Do the EJB's references
just go in the Form and
> > Action Bean and every thing else behaves the same? Are there any obvious
points that I can bring
> > up on the subject?
> > Any help on this subject would be much appreciated!
> >
> > Thanks, Cameron Ingram

Reply via email to