I've got a strange behavior: my method annotated with @PostConstruct
is called twice.
Debugging it, I saw that my search page called it before the command link's action methos mbean.edit
was called. My bean MBeanSearch
is request scoped, my MBean
is view scoped.
My view search.xhtml:
<h:commandLink value="#{var.value}" action="#{mbean.edit}">
<f:param name="id" value="#{var.id}"/>
</h:commandLink>
I've also got a target view var.xhtml.
Relevant extract from my MBean
bean:
public String edit() {
return "/pages/var.xhtml";
}
@PostConstruct
public void initialize() { }
With this code, my @PostConstruct
is called after my edit method and later it is called again.
I think that I'm using the @PostConstruct
in a wrong way (I think MBean
needs to be up before any method). But what is the alternative to edit an object in a page different from the search page?