Uploaded image for project: 'MyFaces Trinidad'
  1. MyFaces Trinidad
  2. TRINIDAD-2038

Need new exception to know whether JSF needs to report the exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0-beta-1
    • 2.0.0-core
    • None
    • None

    Description

      There are cases that exception is thrown in update model phase, like model layer validation failure, by model outside of JSF and the exception is also handled and reported outside of JSF. To avoid the component's local value getting reset to null, JSF needs to be notified when it happens. The proposed solution is to re-throw a special exception to JSF notify it and also let JSF know whether it needs to report the exception.

      Here is the interface of the exception:
      package org.apache.myfaces.trinidad.util;

      /**

      • Interface for exceptions that tells whether the exception should be reported.
      • The implementation of this interface can be thrown to notify an exception without reporting it.
        */
        public interface Reportable { /** * Return false if this exception should not be reported, otherwise true. */ public boolean shouldReportMessage(); }

        Update UIXEditableValue.updateModel(FacesContext context) to take advantage of this API as following
        public void updateModel(FacesContext context)
        {
        ...

      setValid(false);

      // don't report the exception if the exception is a Reportable instance and tells so
      boolean shouldReportingMessage = (e instanceof Reportable) ?
      ((Reportable) e).shouldReportingMessage() :
      true;

      if (shouldReportingMessage)

      { FacesMessage message = MessageFactory.getMessage(e); message = _wrapMessage(message); context.addMessage(getClientId(context), message); }

      }

      Attachments

        1. exception-reporting-JIRA-2038.patch
          2 kB
          hongbing wang
        2. exception-reporting-JIRA-2038.patch
          2 kB
          hongbing wang

        Activity

          People

            darkarena Scott O'Bryan
            hongbing hongbing wang
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: