0 Replies Latest reply on Jun 14, 2008 9:45 PM by virgo47

    Trouble with FacesMessages

    virgo47

      Hello


      I have a registration form with action method that goes like this (if all validation passes):


              public String register(User user) throws NoSuchAlgorithmException {
                      if (!checkLoginAvailable(user)) {
                              FacesContext.getCurrentInstance().addMessage("register:loginDecorate:login",
                                      new FacesMessage("This login is already taken, try another one."));
      //                      facesMessages.addToControl("register:loginDecorate:login",
      //                              "This login is already taken, try another one.");
                              return "fail";
                      }
              ...
              return "ok";
              }
      



      Pages.xml has render after fail outcome. Registration form is rerendered - this all works fine. Originally I wanted to use line that's commented out - the trouble is that no message appeared. Using FacesContext... line all works out. I debugged the code and found out that my messages are stuck in tasks field at that moment. I've tried afterPhase static method (out of desperation ;-)) but still no result.


      What is the real difference between those two approaches? I know that FacesMessages support messages over redirect, etc, etc... but how can I use them for this simple task?


      Thank you