File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Is struts2 Action class suppourts Dependency Injection featuture Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Is struts2 Action class suppourts Dependency Injection featuture" Watch "Is struts2 Action class suppourts Dependency Injection featuture" New topic
Author

Is struts2 Action class suppourts Dependency Injection featuture

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528


Hi all,

I am using Struts2 independently ( what i mean is without using Spring)

Is it possible to refer to the sessionBean with the help of @EJB Annotation inside the Action class of struts?

Anybody please help.


If you want something you never had do something which you had never done
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Anybody on this ??
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Ravi I'm not a pro at this but a google search took me to this page

http://www.tzavellas.com/techblog/2007/07/03/using-dependency-injection-in-struts2-for-stateless-ejbs-part-1/

I found a lot of other pages saying that this cannot be done but this page shows that. I have not tested it though...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Yes Ankit i also saw that link . But I think that going with Spring would be best .
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

RaviNada Kiran wrote:Yes Ankit i also saw that link . But I think that going with Spring would be best .


Well the page that I gave uses a library to do the injection. You said that you are not using Spring that's why I gave that solution...
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Yes what you said is right .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is struts2 Action class suppourts Dependency Injection featuture