Uploaded image for project: 'Shale'
  1. Shale
  2. SHALE-406

ConverterHelper produce NullPointerException by calling Converter with uiComponent = null parameter during restore view phase.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0.4
    • 1.0.5
    • Core, View
    • None
    • Facelets 1.1.12, MyFaces 1.1.5-SNAPSHOT , Tomahawk 1.1.5-SNAPSHOT

    Description

      I had an backing bean class with the following property:

      @Property{value="#

      {param.enrollmentId}")
      private Long enrollmentId;

      And this ends up that shale calls the
      getAsObject method javax.faces.convert.LongConverter of MyFaces-1.1.5-SNAPSHOT during the restore view phase .

      This method expects an uiComponent not null otherwise it throws a
      NullPointerException. But this method is called by the
      org.apache.shale.util.ConverterHelper during create view and therefore
      the facesContext setViewRoot is still null. So the below code of the ConverterHelper
      end ups in a NullPointerException in this situation.

      public Object asObject(FacesContext context, Class type, String value) {
      if (String.class == type) { return value; }
      return converter(context, type).getAsObject(context,context.getViewRoot(), value);
      }

      There are also some other parts in the ConverterHelper class that depends on that viewRoot is not null.

      Well the jsf - 1.1 spec says that the getAsObject method is called during the apply request values phase.
      As far as I understood it myfaces doesn't use the converter to initialize the beans also. Instead it uses the Coercions class of common-el to convert #{param.enrollmentId}

      .

      Btw.: As workaround, define your own ConverterClass that can handle that the component parameter is null.

      • Ingo

      Attachments

        Activity

          People

            gvanmatre@comcast.net Gary VanMatre
            idueppe Ingo Düppe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: