I think the question is clear by the title. This is my actual bean :
@ManagedBean(name="selector")
@RequestScoped
public class Selector {
private String profilePage;
@PostConstruct
public void init() {
System.out.println("I'm PostConstruct");
if(profilePage==null || profilePage.trim().isEmpty()) {
this.profilePage="main";
}
}
public String getProfilePage() {
return profilePage;
}
public void setProfilePage(String profilePage) {
this.profilePage=profilePage;
System.out.println("I'm setProfilePage");
}
}
And i change his value (profilePage) by using ajax call :
<h:commandButton value="Some Action">
<f:setPropertyActionListener target="#{selector.profilePage}" value="some" />
<f:ajax event="action" render=":profileContent"/>
</h:commandButton>
I notice that my output on server is not ever a sequence of I'm PostConstruct
followed by I'm setProfilePage
. Sometimes I'm setProfilePage
is totally absent.
I read that Methods marked with the @PostConstruct annotation will be invoked after the bean has been created, any resources have been injected, and any managed properties set, but before the bean is actually pushed into scope.
I would like to know if @PostConstruct
can make some conflicts with setter method.
Cheers