cancel
Showing results for 
Search instead for 
Did you mean: 

Wizard: Error Message in the same page

lmoulin
Champ in-the-making
Champ in-the-making
Hello,
I have developed a new Wizard.
I have override the next() method.
To display an error, I use the method 'Utils.addErrorMessage'.

public String next()
      {    
         FacesContext context = FacesContext.getCurrentInstance();
         // Verification que tout est saisi
         if (this.firstName.equals("") || this.lastName.equals("") || this.email.equals("") || this.login.equals("") || this.password.equals("") || this.confirmPassword.equals("")) {
            Exception ex = new Exception("Tous les champs sont obligatoires. Veuillez les renseigner.");
            Utils.addErrorMessage(formatErrorMessage(ex), ex);
            return null;
         }

But the system displays the error message in the next page.
Is it possible to display the error message in the same page (without do the next method).

Thanks a lot for your answer.
Luc
2 REPLIES 2

gavinc
Champ in-the-making
Champ in-the-making
You could try doing something like this in your next() method:

Application.getWizardManager().getState().setCurrentStep(Application.getWizardManager().getState().getCurrentStep()-1);

The step counter has already been increased by the time the next() method of your bean gets called, the code above sets the counter back to the previous page.

lmoulin
Champ in-the-making
Champ in-the-making
Thanks a lot. It works.