I have a little problem: when logging out of my cms, SOMEHOW the setter of one of my parameters is called and action performed. It results in http500.
To be specific: I pass the parameter from jsf page to backing (@RequestScoped) bean using:
<f:metadata>
<f:viewParam name="activate" value="#{myManagedBean.activate}" />
it uses setter, which makes changes in database:
public void setActivate(int num) {
ab.changeActiveState("myString", num);
return;
}
logout method is used on completely different bean, and calls simple method:
public String logout() {
Object request = FacesContext.getCurrentInstance().getExternalContext().getRequest();
HttpServletRequest a = (HttpServletRequest) request;
try {
a.logout();
} catch(Exception e) {
logger.info("Error while logout: " + e);
}
return "advert-list.xhtml?faces-redirect=true";
}
Logging out throws errors:
javax.servlet.ServletException: javax.el.ELException: /secure/my-list.xhtml @12,81 value="#{myManagedBean.activate}": javax.ejb.EJBException: javax.persistence.NoResultException: No entity found for query
javax.faces.webapp.FacesServlet.service(FacesServlet.java:321) org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
root cause
javax.faces.component.UpdateModelException: javax.el.ELException: /secure/advert-list.xhtml @12,81 value="#{myManagedBean.activate}": javax.ejb.EJBException:
javax.persistence.NoResultException: No entity found for query
javax.faces.component.UIInput.updateModel(UIInput.java:848)
javax.faces.component.UIViewParameter.updateModel(UIViewParameter.java:284)
javax.faces.component.UIInput.processUpdates(UIInput.java:730)
javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1109)
javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1109)
javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1218) com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:74)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
I have no idea what is going on and why. About that setter - it works as it should. And about logging out - from any other page in my project it doesn't throw anything and logs out current user.