Apparently your bean is the scope of the request and thus is restored with every HTTP request. I’m not quite sure why you want to prevent @PostConstruct from being called @PostConstruct , otherwise you would get an "empty" bean state that could lead to form @PostConstruct errors, but everything is fine, you can add a check if the current request not a postback .
public void init() { if (!FacesContext.getCurrentInstance().isPostback()) {
Thus, part of the “assembly combos” will not be called in reverse gears.
Or maybe your actual question is not, “How to prevent post-construction from calling postback?”, But even more, “How to keep the same bean instance in postback?”. In this case, you will need to place the bean in the viewport, not in the request area.
@ManagedBean @ViewScoped public class Bean implements Serializable {
As long as you return null from the action methods, this way the same bean will work as long as you interact with the same view using postbacks. This way @PostConstruct will not be called (simply because the bean has not been restored).
See also:
source share