I want to know what kind of messages are shown in the current page using EL. I\'m particularly interested in errors above warning severity. My current solution is this:
Until the upcoming EL 3.0, you can't reference constants in EL.
As to open source libraries, the only one which can help you in this is OmniFaces. It offers a <o:importConstants> tag for the very purpose.
<o:importConstants type="javax.faces.application.FacesMessage" />
This way you'll be able to use
#{facesContext.maximumSeverity eq FacesMessage.SEVERITY_ERROR or facesContext.maximumSeverity eq FacesMessage.SEVERITY_FATAL}
or
#{facesContext.maximumSeverity.compareTo(FacesMessage.SEVERITY_WARN) gt 0}
or
#{facesContext.maximumSeverity.compareTo(FacesMessage.SEVERITY_ERROR) ge 0}
or
#{facesContext.maximumSeverity.ordinal gt FacesMessage.SEVERITY_WARN.ordinal}
or
#{facesContext.maximumSeverity.ordinal ge FacesMessage.SEVERITY_ERROR.ordinal}
(note that I omitted the unnecessary get
prefix and ()
parens, IDE-autocomplete in EL doesn't necessarily generate right and clean code)