Tapestry
  1. Tapestry
  2. TAPESTRY-1389

Coercion to numeric types does not check for null

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 5.0.3
    • Fix Version/s: 5.0.6
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      N/A

      Description

      When a TextField form element is bound to a numeric property (Double, Integer, aso) and no value is provided in the form (perfectly valid if the field is optional) the coercion code throws NullPointerException when trying to call new Double(null). The coercion code should check for null and not call the constructor with a null argument.

      On the other hand, if this is considered normal behaviour, there should be a way to bind a TextField to a numeric property and to make it optional on the form.

      Here follows a test case illustrating the problem:

      DoubleCoercionTest.html:
      ------------------------------------

      <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
      <body>
      <form t:type="Form">
      <p><input t:type="TextField" t:value="doubleTest" size="40"/>
      <input t:type="Submit"/></p>
      </form>
      </body>
      </html>

      DoubleCoercionTest.java:
      -----------------------------------
      import org.apache.tapestry.annotations.Persist;

      public class DoubleCoercionTest
      {
      @Persist
      private Double doubleTest;
      public Double getDoubleTest()

      {return doubleTest;}

      public void setDoubleTest(Double doubleTest)

      {this.doubleTest = doubleTest;}

      }

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        Duplicate of TAPESTRY-1648. We now coerce null to numeric types correctly (as the value 0).

        Show
        Howard M. Lewis Ship added a comment - Duplicate of TAPESTRY-1648 . We now coerce null to numeric types correctly (as the value 0).

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Bogdan Calmac
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development