For a project I am updating a Java web application that has some loose ends. I'm having problems with the init-method of a bean, that is called while it should not be.
The page that causes the problems has three buttons to return to three different pages you have visited earlier. Two of these buttons cause the init-method of the bean of the page you are currently on, to be called. You have to press the button again to get the action performed (=return to the other page). The strange thing is: you can arrive at the problem-page via two menu options. One causes the problem, the other way does not. You return to the other page without problems.
Piece of xhtml of the problem-page:
<h:commandButton value="Show batch" action="/BatchDetail.xhtml" />
<h:commandButton value="Show messages" action="/BatchMessage.xhtml" />
<c:if test="#{batchMessageDetailBean.batch.part}">
<h:commandButton value="Show both" action="/BatchAndBatchMessage.xhtml" />
</c:if>
The 'show batch' and 'show messages' cause the problem. The third button is only present via the menu option that causes the problem with the first two buttons. Strangely, this button does not call the init-method again.
I've read about the 'c:if' causing problems, but when I remove it entirely, nothing changes. The bean is @ViewScoped. I'm not using Spring. If you need more details, just ask.
Any ideas?