Board index JavaServer Faces General Issue with Growl and \n Characters in a FacesMessage

Issue with Growl and \n Characters in a FacesMessage

Components, Ajax Framework, Utilities and More.


Posts: 80
After a lot of chasing my tail I found out that an exception that was thrown by some code I was using contained a \n character in the getMessage() method. I was passing this to a FaceMessage() to be displayed by growl and found that growl fell to pieces when it encounters a message with this character.

So basically in my bean's catch statement I had:

facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Unable to process license key!" , e.getMessage()  ) );


Which would only show up some of the time, depending on the exception being thrown by the upstream code. I found that one of the messages had a tailing \n character that cause it to not be displayed in a growl message, so I replaced this with

facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Unable to process license key!" , ( e.getMessage() != null ) ? e.getMessage().replace('\n', ' ') : "") );


So shouldn't growl / PF check for this so the user doesn't have to because you never know what is going to be in the getMessage() statement, especially if it is written by a third party.

I have testing this on the latest snapshot of 2.2 (dec 28th) and the rc2 running on tomcat 6
PrimeFaces 5.0, Mojarra 2.2.6, OpenJDK 7, Tomcat 8, Ubuntu 14.04, Netbeans 8

Return to General