You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Hardy <ah...@cyberspaceroad.com> on 2003/06/19 16:51:10 UTC

design issue MVC - forms, EJB, data marshalling

I am starting a new app and trying to work out the best design approach. 
At the moment I want to get the app up and running, and so I'm just 
going to use tomcat and struts and achieve MVC by seperating out the 
database access into factory classes.

At some point after I've got the project running, I want to replace the 
factory layer with CMP entity beans in JBoss (mostly for the learning 
experience). I've read Mastering EJB by Roman et al and so have a 
newby's idea of what the benefits would be although I'd like to hear 
what some gurus out there who've got experience with CMP say.

My doubts are about whether entity beans can handle what I want to do. 
After I finished a successful project (not using EJB) which handled 
data-intensive lists with nested tags, I'm thinking of pursuing that 
design paradigm further. The value beans were created in the factories 
and passed into the action forms for use by the nested tags. The value 
beans had a validate() method, which took a Locale as the parameter when 
necessary, e.g. for date validation.

Now I'm not sure if I can use the same principle in EJB. Can I take an 
CMP entity bean out of the J2EE container and use it in a struts form? 
And the reverse - can I pass a bean back again with updated values?

Thanks
Adam


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


Re: design issue MVC - forms, EJB, data marshalling

Posted by Erik Price <ep...@ptc.com>.

Mike Jasnowski wrote:
> Actually I wasn't referring to "OLE" as in M$ speak, Ole is just a short
> version of "Old" :)

But not much shorter! ;)



Erik


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


RE: design issue MVC - forms, EJB, data marshalling

Posted by Mike Jasnowski <mj...@bea.com>.
Actually I wasn't referring to "OLE" as in M$ speak, Ole is just a short
version of "Old" :)

-----Original Message-----
From: Laurent PETIT [mailto:lpetit@sqli.com]
Sent: Thursday, June 19, 2003 2:17 PM
To: Struts Users Mailing List
Subject: Re: design issue MVC - forms, EJB, data marshalling


---- Original Message -----
From: "Mike Jasnowski" <mj...@bea.com>
> POJO = Plain Ole Java Object
                          ^^^^

POJO = Plain Old Java Object

( nothing to do with Ole & M$, just a typo )

--
Laurent


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


Re: design issue MVC - forms, EJB, data marshalling

Posted by Laurent PETIT <lp...@sqli.com>.
---- Original Message ----- 
From: "Mike Jasnowski" <mj...@bea.com>
> POJO = Plain Ole Java Object
                          ^^^^

POJO = Plain Old Java Object

( nothing to do with Ole & M$, just a typo )

-- 
Laurent


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


RE: design issue MVC - forms, EJB, data marshalling

Posted by Mike Jasnowski <mj...@bea.com>.
POJO = Plain Ole Java Object

-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
Sent: Thursday, June 19, 2003 1:01 PM
To: Struts Users Mailing List
Subject: Re: design issue MVC - forms, EJB, data marshalling


I decided that I didn't have time to dive straight into EJB, although 
I'm taking far more time than expected on the design. Hmph!

Thanks for the input. What though is POJO?

Erik Price wrote:
> I think it would be better to employ the session facade pattern, perhaps 
> using a Session bean, for a couple reasons.
> 
> 1) you don't expose the entity beans (essentially they are wrapped 
> "privately" in the session facade)
> 2) you can populate some POJOs like "value objects" or whatever from the 
> data in the entity beans
> 
> Note that if you are using CMP (esp 2.0), you may find it faster to 
> simply develop with CMP and skip the factory business (unless your 
> "factory classes" really are just prototypes and you don't spend too 
> much time perfecting and goldplating them) -- the whole point is that 
> you don't have to do all the hand-coding when you use CMP.  Use XDoclet 
> to spare yourself the hassle of generating all the boilerplate, and some 
> app servers (such as JBoss) have XDoclet tags that will generate the 
> database for you.
> 
> See xpetstore-ejb (<http://xpetstore.sourceforge.net/>) for an example 
> of this.
> 
> 
> Erik


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


Re: design issue MVC - forms, EJB, data marshalling

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
I decided that I didn't have time to dive straight into EJB, although 
I'm taking far more time than expected on the design. Hmph!

Thanks for the input. What though is POJO?

Erik Price wrote:
> I think it would be better to employ the session facade pattern, perhaps 
> using a Session bean, for a couple reasons.
> 
> 1) you don't expose the entity beans (essentially they are wrapped 
> "privately" in the session facade)
> 2) you can populate some POJOs like "value objects" or whatever from the 
> data in the entity beans
> 
> Note that if you are using CMP (esp 2.0), you may find it faster to 
> simply develop with CMP and skip the factory business (unless your 
> "factory classes" really are just prototypes and you don't spend too 
> much time perfecting and goldplating them) -- the whole point is that 
> you don't have to do all the hand-coding when you use CMP.  Use XDoclet 
> to spare yourself the hassle of generating all the boilerplate, and some 
> app servers (such as JBoss) have XDoclet tags that will generate the 
> database for you.
> 
> See xpetstore-ejb (<http://xpetstore.sourceforge.net/>) for an example 
> of this.
> 
> 
> Erik


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


Re: design issue MVC - forms, EJB, data marshalling

Posted by Erik Price <ep...@ptc.com>.

Adam Hardy wrote:
> I am starting a new app and trying to work out the best design approach. 
> At the moment I want to get the app up and running, and so I'm just 
> going to use tomcat and struts and achieve MVC by seperating out the 
> database access into factory classes.
> 
> At some point after I've got the project running, I want to replace the 
> factory layer with CMP entity beans in JBoss (mostly for the learning 
> experience). I've read Mastering EJB by Roman et al and so have a 
> newby's idea of what the benefits would be although I'd like to hear 
> what some gurus out there who've got experience with CMP say.
> 
> My doubts are about whether entity beans can handle what I want to do. 
> After I finished a successful project (not using EJB) which handled 
> data-intensive lists with nested tags, I'm thinking of pursuing that 
> design paradigm further. The value beans were created in the factories 
> and passed into the action forms for use by the nested tags. The value 
> beans had a validate() method, which took a Locale as the parameter when 
> necessary, e.g. for date validation.
> 
> Now I'm not sure if I can use the same principle in EJB. Can I take an 
> CMP entity bean out of the J2EE container and use it in a struts form? 
> And the reverse - can I pass a bean back again with updated values?

I think it would be better to employ the session facade pattern, perhaps 
using a Session bean, for a couple reasons.

1) you don't expose the entity beans (essentially they are wrapped 
"privately" in the session facade)
2) you can populate some POJOs like "value objects" or whatever from the 
data in the entity beans

Note that if you are using CMP (esp 2.0), you may find it faster to 
simply develop with CMP and skip the factory business (unless your 
"factory classes" really are just prototypes and you don't spend too 
much time perfecting and goldplating them) -- the whole point is that 
you don't have to do all the hand-coding when you use CMP.  Use XDoclet 
to spare yourself the hassle of generating all the boilerplate, and some 
app servers (such as JBoss) have XDoclet tags that will generate the 
database for you.

See xpetstore-ejb (<http://xpetstore.sourceforge.net/>) for an example 
of this.


Erik


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