FacesMessage.Severity

Severity

Severity

<rich:notifyMessages/>

<rich:notifyMessages/>

<rich:messages/>

Problem

<rich:notifyMessages/>

Severity

Solution

FacesMessage.Severity

default.css

iconURL()

References

We encountered an inconsistency between MyFaces and Mojarra that I was surprised was not addressed a long time ago. The issue has to do with the ordinal values assigned to the. Mojarra uses a zero(0) based level ofand MyFaces uses a one(1) basedlevel. As a result, we were trying to use acomponent with, as you can expect, some unexpected results.One of the items I always preach is to code to the API. If you code to the API, then you can switch out the implementations should the need occur. This is a best practice, but can be undermined by little subtleties like this. Please don't get me wrong, both Mojarra and MyFaces are great implementations. It is these fine differences that should be consistent that we need to work on to make sure that we are consistent, and that the dream is real; switching implementations will not be painful.RichFaces is a good framework, and folks like Brian Leathem take personal pride in making it a good implementation to run on top of either Mojarra, or MyFaces. I was really surprised by my discovery of an issue withsince theworks correctly. The problem is focused on the ordinal value I mentioned. I opened a JIRA issue with both MyFaces and RichFaces around the ordinal issue. Please see the references below for details.However, I needed a solution not just report an issue. So I came up with a 10¢ solution based on some work I did at home last night, and a great suggestion by one of my team. I wanted to publish an article, a complaint, and a solution that others may need. These work arounds tend to become more common when doing cross-platform development, and sharing is paramount.The RichFacesdoes not work consistently across JSF implementations based onordinal values.Implement a method that checks theordinal values, and change icons and CSS to correct the differences between implementations. We can accomplish this using CSS, and Expression Language (EL) combined with a page backing bean. In this case, I use a simple page backing bean, but it could be converted to a custom EL function.The code for this example can be found here: myfaces-rf-example This simple solution allows us to check to see if the implementation starts at 0, or 1 and changes the icons and CSS.