This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes @Inject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "@Inject" Watch "@Inject" New topic
Author

@Inject

Mudit Srivastava
Ranch Hand

Joined: Apr 30, 2007
Posts: 38
Hi All,

How can i use the @Inject annotation in my actions.

Regards
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Take a look at how S2 itself uses it--your own code can use it in the exact same way.
Mudit Srivastava
Ranch Hand

Joined: Apr 30, 2007
Posts: 38
Thanks David. Do you know a link/Class I could refer to.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

All you need to do is annotate a setter with the name of the constant you want to inject. Other uses are possible; it's an early fork of Guice, so Guice docs/books might be of assistance.
 
 
subject: @Inject
 
Similar Threads
Access EJB out of WAR in JBoss 6
Struts 2 EJB injection
spring wont inject the entitymanager
Exception in thread "main" org.springframework.beans.factory.BeanCreationException:
How to get Stateful bean from SessionFacade