Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts and EJB  RSS feed

 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am using EJB2.0 struts 1.1 on Weblogic 8.

I had an application in struts and now I am implementing EJBs in this same application.
in many cases , my EJBs ( actually DAOs )require ActionForm data. because my ActionForms have many attributes , in the arguements I pass the form itself.
i.e many of my DAO's methods are like this: method(CandidateForm candidateForm) where "CandidateForm" is an ActionForm.

This puts restriction ,i.e I can't seperate my EJBs and ActionForms as sepearte projects ( meaning that I can't seperate EJBs and move'em to diffrent machine). so I can't make use of EJBs !!!

Can anybody give me solution , How can I use ActionForm data in EJBs ???
One of the solutions can be "sending a Collection of all attributes of ActionForm" in arguement..

I am misssing something , Please guide me

Thanks
-Anand.
 
s penumudi
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One solution would be
In your Action class before calling your EJB service, convert the ActionForm data into some value objects or transfer objects and pass these objects as the input parameter to your EJB.
With the above approach you will have to change the datatypes in the ejb method signatures.
Then make ur struts classes as seperate project, valueobjects as seperate objects, ejb as seperate project. include value object project in youe strus and ejb projects as these are accessed by both the projects.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a DTO and send the same to EJB.even sending collection is not bad idea.

but NEVER send your Action Form to EJB

hope this helps
 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by s penumudi:
One solution would be
In your Action class before calling your EJB service, convert the ActionForm data into some value objects or transfer objects and pass these objects as the input parameter to your EJB.
With the above approach you will have to change the datatypes in the ejb method signatures.
Then make ur struts classes as seperate project, valueobjects as seperate objects, ejb as seperate project. include value object project in youe strus and ejb projects as these are accessed by both the projects.


Creating Value Object and passing it into the EJB classes is good idea and also seperation of bussiness logic.
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but NEVER send your Action Form to EJB


I think If I go making a DTO , it would be almost same as ActionForm !!

What's the logic for not sending ActionForm to EJB ???
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two projects
NEA ( Struts classes and JSPs)
NEA_ejb ( Ejb classes.i.e Home interface,remoter interface and Bean)

ejb classes require ActionForms,i.e NEA_ejb uses NEA. Other side , NEA uses ejbs,i.e NEA uses NEA_ejb.

meaning that , NEA and NEA_ejb are both dependent on each other and thus ending up in a Loop of dependencies !!!

Any ideas ? thanks
-Anand.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anand Gondhiya:


What's the logic for not sending ActionForm to EJB ???



There are two very common mistake that we do in struts

1. Putting buisness Logic in Action Class
2. Treating ActionForm as DTO

ActionForm are part of View Componet in Struts.

Struts Frame Work automatically collects input from request and populate the action form and for this frame work uses servlet API's

Sending ActionForm to EJB will break the de-coupling of web-continer and ejb contianer.

also view componet will be coupled with Model of MVC .

and as per MVC model is unaware of type of client being used.

hope this answers your query....
[ December 02, 2004: Message edited by: Shailesh Chandra ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!