Bean annotations like @ManagedProperty and @PostConstruct doesn't work when manually instantiating the bean from another bean
-
29-10-2019 - |
문제
I instantiated a request bean from another request bean,
new LoginManager();
But the property which is annotated with @ManagedProperty
doesn't get the value from the asked reference, only in case of instantiation through the above way. It just contains null
, causing NPE later in code. Also @PostConstruct
won't be invoked. Why is it so & how should I deal with this?
@ManagedBean(name = "loginManager")
@RequestScoped
public class LoginManager {
private String userid;
private String password;
@ManagedProperty(value="#{currentSession}")
private UserSessionManager userSession;
}
But userSession
can't read from the session scoped bean when this bean was instantiated using: new LoginManager();
However I can read the value using FacesContext
!
올바른 솔루션이 없습니다
제휴하지 않습니다 StackOverflow