I have a login page:
<h:form id="f_login" >
<f:passThroughAttribute name="data-ajax" value="false" />
<h:messages id="message" showDetail="false" errorClass="error_msg" fatalClass="success_msg" infoClass="info_msg" warnClass="warning_msg" />
<h:inputText value="#{loginWEB.user.email}" >
<f:passThroughAttribute name="placeholder" value="Email" />
<f:ajax event="change" execute="@this" />
</h:inputText>
<h:inputSecret value="#{loginWEB.user.senha}" autocomplete="off" >
<f:passThroughAttribute name="placeholder" value="Senha" />
<f:ajax event="change" execute="@this" />
</h:inputSecret>
<h:commandButton id="btn_login" value="Login" action="#{loginWEB.login()}" >
<f:passThroughAttribute name="data-theme" value="g" />
<f:ajax render="message" />
</h:commandButton>
</h:form>
With this action method:
public void login() {
try {
FacesContext context = FacesContext.getCurrentInstance();
if (...) { //Verify email and password
context.getExternalContext().redirect("/templates/main.xhtml");
}
else {
FacesMessage message = new FacesMessage("Invalid email or password");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(null, message);
}
} catch (Exception e) {
Logger.getLogger(LoginWEB.class.getName()).log(Level.SEVERE, null, e);
}
}
Submitting this form sometimes causes a JS error:
httpError: The Http Transport returned a 0 status code. This is usually the result of mixing ajax and full requests. This is usually undesired, for both performance and data integrity reasons.
I don't understand what I'm doing wrong. How is this caused and how can I solve it?