PostConstruct is called twice

╄→尐↘猪︶ㄣ 提交于 2019-12-01 11:41:00
xild

we have this problem here, but is a problem with WebSphere 6. (runaway from websphere :D)

So... we do a little workaround to use @PostConstruct...
Maybe can help you...

public boolean firstInit() {
    boolean firstInit= false;
        try {
            FacesContext context = FacesContext.getCurrentInstance();
            firstInit= context != null  && context.getExternalContext().getRequestParameterMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM);
        } catch (Exception e) {
            firstInit= false;
        }
        return firstInit;
    }
public void init(){
if (firstInit()) return;
//init methods
}

And @PostConstruct method called twice for the same request this can help you too...

obs: i cant write comments :/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!