This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSF and the fly likes @PostConstruct Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "@PostConstruct" Watch "@PostConstruct" New topic
Author

@PostConstruct

Marcos Vidolin
Greenhorn

Joined: May 10, 2011
Posts: 28
Hello all,

May I use an @Autowired object from Spring inside my @PostConstruct method?

Tks
[]'s
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

I think that Autowired is used by Spring to construct beans and (no surprise here!) automatically wire them together.

A JSF backing bean, however, is constructed by JSF, not by Spring. The JSF equivalent of @Autowired is @ManagedProperty.

The main functional difference between the 2 annotations is that @ManagedProperty accepts an EL expression instead of simply deducing the source property's bean name.

Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @PostConstruct
 
Similar Threads
@PostConstruct == ejbPostCreate( ) ?
ejbPostCreate() in EJB 2.1
Need to call a method to populate my list, then have that list bound to rich tree
suppourt for Annotation Programming . In servlets
Many @PostConstruct methods?