Details

      Description

      The severity of a FacesMessages (SEVERITY_INFO, SEVERITY_WARN, SEVERITY_ERROR or SEVERITY_FATAL) is mentioned only once in the JSF spec (section 6.3 FacesMessage). Even then, this is only to enumerate its possible values.

      The four severity values are arguably self explanatory, but at least one point would bear some clarification. Specifically: is it still considered a validation error if the severity is INFO?

      Section 6.3 descibes all severity values as a 'problem' of some kind ('how serious the problem'). Section 2.2.2 indicates "validations that failed will have caused messages to be enqueued via calls to the addMessage() method". So this does indeed seem to suggest that SEVERITY_INFO (and SEVERITY_WARN) are in fact validation errors - in the sense that they cause the 'Process Validations' lifecycle stage to fail.

      Can this be stated explicitly in the spec? The severity names are a bit misleading. I have had users of my widget library question whether SEVERITY_INFO should be considered a validation error. Specifically they have questioned whether...

      if ( FacesContext.getCurrentInstance().getMaximumSeverity() != null )

      ...is a valid way to check for the presence of a validation error.

        Activity

        Hide
        kennardconsulting added a comment -

        Brian Leathem has helpfully pointed out there was a FacesContext.isValidationFailed method introduced in JSF 2.0. It does not rely on FacesMessage at all.

        Unfortunately it appears to be quite 'baked in' to the JSF 2.0 internals (eg. now UIInput calls FacesContext.validationFailed as well as FacesContext.responseComplete). So I cannot replicate it for JSF 1.x compatibility.

        Is there an equivalent to FacesContext.isValidationFailed for JSF 1.x?

        Show
        kennardconsulting added a comment - Brian Leathem has helpfully pointed out there was a FacesContext.isValidationFailed method introduced in JSF 2.0. It does not rely on FacesMessage at all. Unfortunately it appears to be quite 'baked in' to the JSF 2.0 internals (eg. now UIInput calls FacesContext.validationFailed as well as FacesContext.responseComplete). So I cannot replicate it for JSF 1.x compatibility. Is there an equivalent to FacesContext.isValidationFailed for JSF 1.x?
        Hide
        Ed Burns added a comment -

        Regarding isValidationFailed() for JSF 1.x: No, there is not.

        Regarding a decent definition of the logging levels, that is not something we have considered. While it is true that FacesMessage is a JSF class, when we do consider logging levels, they should be considered at the lowest level of the stack as possible.

        JavaEE spec section EE.6.2.4.9 explicitly declares the platform spec
        doesn't require the logging of any certain events.

        I'll put a query in to the Titans of JavaEE about this.

        In the meantime, I do agree with your suggestion that even INFO messages should be considered a validation failure.

        I'll update the spec accordingly.

        Show
        Ed Burns added a comment - Regarding isValidationFailed() for JSF 1.x: No, there is not. Regarding a decent definition of the logging levels, that is not something we have considered. While it is true that FacesMessage is a JSF class, when we do consider logging levels, they should be considered at the lowest level of the stack as possible. JavaEE spec section EE.6.2.4.9 explicitly declares the platform spec doesn't require the logging of any certain events. I'll put a query in to the Titans of JavaEE about this. In the meantime, I do agree with your suggestion that even INFO messages should be considered a validation failure. I'll update the spec accordingly.
        Hide
        Ed Burns added a comment -

        Sending perRequestStateInformation.fm
        Sending preface.fm
        Transmitting file data ..
        Committed revision 1031.

        Show
        Ed Burns added a comment - Sending perRequestStateInformation.fm Sending preface.fm Transmitting file data .. Committed revision 1031.
        Hide
        kennardconsulting added a comment -

        Thanks Ed,

        So this would mean that...

        if ( context.getMaximumSeverity() != null )

        ...is a valid way to test if a validation error has occurred in JSF 1.2? Googling for "getMaximumSeverity() != null" this seems to be used by a few people?

        Regards,

        Richard.

        Show
        kennardconsulting added a comment - Thanks Ed, So this would mean that... if ( context.getMaximumSeverity() != null ) ...is a valid way to test if a validation error has occurred in JSF 1.2? Googling for "getMaximumSeverity() != null" this seems to be used by a few people? Regards, Richard.
        Hide
        Ed Burns added a comment -

        Yes, this seems reasonable and safe.

        Show
        Ed Burns added a comment - Yes, this seems reasonable and safe.
        Hide
        lu4242 added a comment -

        I think it is questionable. Take a Look UIData.encodeBegin javadoc description:

        "... In addition to the default behavior, ensure that any saved per-row state for our child input components is discarded unless it is needed to rerender the current page with errors. ..."

        There is a check to preserve the model if there is no validation error, looking for no messages with SEVERITY_ERROR.

        That description comes from JSF 1.1. If an info message is considered a validation error, is this description wrong?

        I was about to ask if we can change that part to use FacesContext.isValidationFailed for JSF 2.0 and upper, instead of rely on this "weird" logic.

        Show
        lu4242 added a comment - I think it is questionable. Take a Look UIData.encodeBegin javadoc description: "... In addition to the default behavior, ensure that any saved per-row state for our child input components is discarded unless it is needed to rerender the current page with errors. ..." There is a check to preserve the model if there is no validation error, looking for no messages with SEVERITY_ERROR. That description comes from JSF 1.1. If an info message is considered a validation error, is this description wrong? I was about to ask if we can change that part to use FacesContext.isValidationFailed for JSF 2.0 and upper, instead of rely on this "weird" logic.
        Hide
        kennardconsulting added a comment -

        I agree FacesContext.isValidationFailed is a much better choice for JSF 2. We just need to agree what the equivalent should be for JSF 1.

        If UIData is looking only for SEVERITY_ERROR, then...

        if ( context.getMaximumSeverity() != null )

        ...is not going to cut it. Perhaps the answer would be in understanding why FacesContext.isValidationFailed was introduced? Were people confused about this area? If so, what was the confusion?

        Show
        kennardconsulting added a comment - I agree FacesContext.isValidationFailed is a much better choice for JSF 2. We just need to agree what the equivalent should be for JSF 1. If UIData is looking only for SEVERITY_ERROR, then... if ( context.getMaximumSeverity() != null ) ...is not going to cut it. Perhaps the answer would be in understanding why FacesContext.isValidationFailed was introduced? Were people confused about this area? If so, what was the confusion?
        Hide
        Manfred Riem added a comment -

        Closing resolved issue out

        Show
        Manfred Riem added a comment - Closing resolved issue out

          People

          • Assignee:
            Ed Burns
            Reporter:
            kennardconsulting
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2 days
              2d
              Remaining:
              Remaining Estimate - 2 days
              2d
              Logged:
              Time Spent - Not Specified
              Not Specified