You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Bogdan Calmac (JIRA)" <de...@tapestry.apache.org> on 2007/03/29 06:57:25 UTC

[jira] Created: (TAPESTRY-1389) Coercion to numeric types does not check for null

Coercion to numeric types does not check for null
-------------------------------------------------

                 Key: TAPESTRY-1389
                 URL: https://issues.apache.org/jira/browse/TAPESTRY-1389
             Project: Tapestry
          Issue Type: Bug
          Components: Framework
    Affects Versions: 5.0.3
         Environment: N/A
            Reporter: Bogdan Calmac


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;}
}



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Resolved: (TAPESTRY-1389) Coercion to numeric types does not check for null

Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-1389?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship resolved TAPESTRY-1389.
--------------------------------------------

       Resolution: Duplicate
    Fix Version/s: 5.0.6
         Assignee: Howard M. Lewis Ship

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

> Coercion to numeric types does not check for null
> -------------------------------------------------
>
>                 Key: TAPESTRY-1389
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-1389
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 5.0.3
>         Environment: N/A
>            Reporter: Bogdan Calmac
>            Assignee: Howard M. Lewis Ship
>             Fix For: 5.0.6
>
>
> 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;}
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org