2 Replies Latest reply on Jul 30, 2009 8:16 AM by John Who

    displaying errormessages

    John Who Newbie

      Hi,

      I'm trying to display some error messages. Sometimes it works, sometime it doesn't.

      F.ex. before a user call some action methods I check if he contains the right to do this. If he doesn't I want to display an error message.

      if( !rightMB.hasRight( XYZ ) ){
       addErrorMessage( "form", Constants.ERROR_RIGHT );
      }
      
      public void addErrorMessage(String form, String errorMessage) {
       logger.info("add error!");
       FacesMessage message = new FacesMessage(errorMessage);
       getContext().addMessage(form, message);
      }
      


      This is the output in the webserver console:
      BEFORE RESTORE_VIEW 1
      AFTER RESTORE_VIEW 1
      BEFORE APPLY_REQUEST_VALUES 2
      AFTER APPLY_REQUEST_VALUES 2
      BEFORE PROCESS_VALIDATIONS 3
      AFTER PROCESS_VALIDATIONS 3
      BEFORE UPDATE_MODEL_VALUES 4
      AFTER UPDATE_MODEL_VALUES 4
      BEFORE INVOKE_APPLICATION 5
      Hibernate: select distinct rollerecht0_.RECHT as col_0_0_ from fkv.ROLLE_RECHT rollerecht0_ where rollerecht0_.ROLLE=?
      add error!
      AFTER INVOKE_APPLICATION 5
      BEFORE RENDER_RESPONSE 6
      30.07.2009 12:00:28 com.sun.faces.lifecycle.RenderResponsePhase execute
      INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=hauptkagForm[severity=(INFO 0), summary=(Sie haben nicht das notwendige Recht um diese Funktion aufzurufen!), detail=(Sie haben nicht das notwendige Recht um diese Funktion aufzurufen!)]
      AFTER RENDER_RESPONSE 6

      But there is no error message at the jsp page.
      (Of course I'.having a h:messages tag and the form name is the id of the form of the jsp page)

      Any ideas? Thanks in advance.