It seems that the event preRenderViewis fired only once during the construction of the view and is not fired on subsequent requests on the same view. This is not true. An event preRenderViewis fired just before the view is visualized. A view is displayed in each request . This also includes ajax requests (how else should it generate the necessary HTML output for ajax requests?). Thus, the behavior you see is fully expected. You just used the wrong tool to work.
You must either use the method @PostConstructfor @ViewScopedbean,
@ManagedBean
@ViewScoped
public class Bean {
@PostConstruct
public void init() {
}
}
or add a denial check on the FacesContext#isPostback()render preview event listener
public void preRender() {
if (!FacesContext.getCurrentInstance().isPostback()) {
}
}
See also: