Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4051

FacesMessage.Severity always set to ERROR after ValidatorException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.10
    • 1.2.13, 2.0.25, 2.1.19, 2.2.11
    • None
    • None
    • Tomcat, WebSphere Liberty

    Description

      The severity of messages is always set (overwritten) to SEVERITY_ERROR when a ValidatorException is thrown during validation. In org.apache.myfaces.view.facelets.compiler._ComponentUtils I see that we always call

      facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);

      when processing a ValidatorException. This might make sense if we're assuming that all faces messages default to some other severity, but it doesn't seem right to me that we're overwriting user-set message severities. For example, given the following custom validator:

      public void validate(FacesContext context, UIComponent component, Object value) {
      if (value == null)

      { List<FacesMessage> messageList = new ArrayList<>(); messageList.add(new FacesMessage(FacesMessage.SEVERITY_INFO, "ValidatorException#SEVERITY_INFO", "ValidatorException#SEVERITY_INFO")); throw new ValidatorException(messageList); }

      }

      The severity of the custom message will always be set to SEVERITY.ERROR. I don't see much guidance in the spec on this, but Mojarra behaves differently - it does not overwrite custom FacesMessage severities.

      Attachments

        1. MYFACES-4051.patch
          4 kB
          Bill Lucy

        Activity

          People

            wtlucy Bill Lucy
            wtlucy Bill Lucy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: