DD.
DD.

Reputation: 21971

@ManagedProperty equivalent in Spring

I am using Spring for my DI. Is there an equivalent of @ManagedProperty? I want to inject the value from one view scoped bean into another one on the next page.

e.g

@Component
@Scope("view")
public class Page1Bean(){
   private String value;
}

@Component
@Scope("view")
public class Page2Bean(){
    @ManagedProperty(value = #{page1Bean}")  //doesnt work in Spring
    private Page1Bean bean;
}

Upvotes: 1

Views: 1190

Answers (1)

digitaljoel
digitaljoel

Reputation: 26574

@Resource or @Autowired should work. @Resource is the Java EE implementation, @Autowired is the spring specific annotation. I can't find the reference now, but it seems like I read once to prefer @Resource over @Autowired.

here's a blog post I found that talks about @Inject vs. @Resource vs. @Autowired http://blogs.sourceallies.com/2011/08/spring-injection-with-resource-and-autowired/#more-2350

Upvotes: 1

Related Questions