I'm willing to call a method like this :
<h:commandButton value="Register" action="#{account.action}"/>
With a class like follow :
package com.sources;
public class Account {
private String password1;
private String password2;
public String getPassword1() {
return password1;
}
public void setPassword1(final String password1) {
this.password1 = password1;
}
public String getPassword2() {
return password2;
}
public void setPassword2(final String password2) {
this.password2 = password2;
}
public void action() {
//if the passwords matchs
//change page
//else
//display an error on the xhtml page
}
}
In the method, I would like to change the page or display an error, depending on the validity of the registration.
The action to change the page would be the same as follow, but called in the method #{account.action}
:
<h:commandButton value="Register" action="connect"/>