Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-2254

ValueEncoders created by HibernateEntityValueEncoder produces exceptions on empty clientValue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 5.0.12
    • None
    • tapestry-hibernate
    • None

    Description

      the toValue() method of the ValueEncoder created by the HibernateEntityValueEncoder service tries coercing the clientValue to the primary key field type even if it is empty. this creates a coercion exception.

      public E toValue(String clientValue)

      { Class<?> idType = _idGetter.getReturnType(); // cannot coerce if clientValue is empty Object id = _typeCoercer.coerce(clientValue, idType); Serializable ser = Defense.cast(id, Serializable.class, "id"); return (E)_session.get(_entityClass, ser); }

      the created ValueEncoder should return null if the client Value is empty/null

      this situation arises when a select component is submitted with the blank option selected (see blankOption parameter of select component). as long as there is no required validator associated with the select box null is a valid value (a list of entities is used for the SelectModel).

      furthermore there is no way to override/decorate the HibernateEntityValueEncoder nor to exclude certain entities from having ValueEncoders created. this is useful when custom ValueEncoders are provided. in existing applications the custom ValueEncoders for the entities are quietly ignored.

      Attachments

        Activity

          People

            hlship Howard Lewis Ship
            kristian Kristian Marinkovic
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: