You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Lukasz Jazgar (JIRA)" <ji...@apache.org> on 2009/05/01 16:07:30 UTC

[jira] Updated: (TAP5-595) Binding of Boolean parameter - Coercion null -> false

     [ https://issues.apache.org/jira/browse/TAP5-595?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Jazgar updated TAP5-595:
-------------------------------

    Affects Version/s: 5.1.0.4

> Binding of Boolean parameter - Coercion null -> false
> -----------------------------------------------------
>
>                 Key: TAP5-595
>                 URL: https://issues.apache.org/jira/browse/TAP5-595
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.4, 5.0.18
>            Reporter: Lukasz Jazgar
>            Assignee: Howard M. Lewis Ship
>
> Null value of Boolean (non-primitive type) property is coerced to false, when passed to parameter of type Boolean.
> There is a example below showing this behavior:
> Component with Boolean parameter.
> BooleanComponent.java:
> public class BooleanComponent {
>    @Parameter
>    private Boolean value;
>    boolean beginRender(MarkupWriter writer) {
>        if (value!=null)
>            writer.write("Component's parameter value:" + value);
>        else
>            writer.write("Component's parameter value is NULL);
>        return false;
>    }
> }
> Page passing property of type Boolean as a parameter to component BooleanComponent.
> BooleanTestPage.tml:
> <html xmlns="http://www.w3.org/1999/xhtml"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
>     xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance
> http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd"
>        >
>    <body>
>        PageProperty: ${boolProperty} <br/>
>        BooleanComponent: <t:booleanComponent t:value="boolProperty"/>
>    </body>
> </html>
> BooleanTestPage.java:
> public class BooleanTestPage {
>    @Property
>    private Boolean boolProperty;
>    void onActivate(String yesNoNullStr) {
>        if (yesNoNullStr.equalsIgnoreCase("yes"))
>            boolProperty = true;
>        else if (yesNoNullStr.equalsIgnoreCase("no"))
>            boolProperty = false;
>        else
>            boolProperty = null;
>    }
> }
> Observed behavior:
> 1.
> http://localhost:8080/web/booleanTestPage/yes
> Result:
>        PageProperty: true
>        BooleanComponent: Component's parameter value: true
> OK
> 2.
> http://localhost:8080/web/booleanTestPage/no
> Result:
>        PageProperty: false
>        BooleanComponent: Component's parameter value: false
> OK
> 3.
> http://localhost:8080/web/booleanTestPage/null
> Result:
>        PageProperty:
>        BooleanComponent: Component's parameter value: false    <---------------!!!!!!!
> Why value of component parameter is false. Shouldn't be null?

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