Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejb call from Action or FormBean

 
ram data
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I am new to Struts world. From which class I need to call EJB? Is it from Action class or FormBean class

Pls clarify

Thanks
Ram
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a Model/View/Controller framework such as Struts, an Action class is the main controller class that you write. The job of a controller class is to act as a mediator between the Model and the view. If you're using EJBs for your Model, it makes sense that the Action class becomes the client for your EJBs. It then sends information to the view based on what it retrieves from the EJB layer. An ActionForm is a class that is more tightly-coupled with the view, and therefore is not a good place to interact with a model-layer object such as an EJB.
 
ram data
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

But i am confused with the following link from ibm
http://publib.boulder.ibm.com/infocenter/radhelp/v6r0m1/index.jsp?topic=/com.ibm.etools.struts.doc/topics/cstrdoc001.html

Could you clarify for me?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I glanced at the article, and there is a lot of good information there. I'm happy to clarify, but you'll have to tell me specifically what it is you find confusing about the article.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, now I see what you mean. The article has a diagram showing a line between the business logic and the the form bean.

All I can say is that I don't agree with the diagram. If I had drawn it, the line would be between the Action class and the business logic. While the ActionForm will certainly contain data sent from the model, it is the Action class that should control the interaction and then populate the ActionForm. It should not be populated directly from the model layer.

For one thing, if you did this, you would introduce a dependency on Struts into your Model layer, which is not desirable.
 
ram data
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the clarification
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ram data,

You're welcome.

However, before posting again, there's something I'd like you to take care of. Since "ram data" is an obviously fictitious name, it is in violation of our naming policy, which we take quite seriously. Please change the "publicly displayed name" in youruser profile so that it conforms to the JavaRanch naming policy.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic