You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Roger L. Whitcomb" <Ro...@actian.com> on 2013/01/02 22:01:43 UTC

RE: Problem using wtk.content.NumericSpinnerData

Okay, I found the problem.  It is rather technical, but basically here’s what’s happening:

1)      When, in BXML, you specify a child element that starts with a Capital Letter, this is instantiated as an object (in this case NumericSpinnerData), which is then attached to the parent *somehow* (and therein lies the rub).  If the parent has a DefaultProperty annotation, then a BeanAdapter is created for the parent, and the DefaultProperty property is set.  For a Spinner, the DefaultProperty is “spinnerData” (as you would expect).

2)      But, inside BXMLSerializer if the value of the existing DefaultProperty property is a Sequence, then the child element is added via Sequence.add(child).  For a Spinner the initial spinner data is an empty ArrayList, which happens to be a Sequence, and so the NumericSpinnerData is added as an element of the ArrayList.  Thus the value turns into the “toString()” value of the NumericSpinnerData object (which is its class name).  So, instead of setting the NumericSpinnerData object itself as the spinner data, it simply adds it to the original ArrayList.

3)      This can be worked around by either using the <spinnerData> as the enclosing element in BXML or by instantiating the NumericSpinnerData in Java code and calling “setSpinnerData” with it.

 

So, I can see two possible solutions:

a)      The Spinner tutorial code (in tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.bxml) actually has this code, which is why it works:

 

        <Spinner preferredWidth="40" selectedIndex="0">

            <spinnerData>

                <content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/>

            </spinnerData>

        </Spinner>

 

                But, the associated display code in tutorials/www/spinners.xml only has this:

                    <Spinner preferredWidth="40" selectedIndex="0">

                        <content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/>

                    </Spinner>

 

                Which doesn’t work because of the problem outlined above.

                So, we could/should change the displayed example code to be what actually works (i.e., change “spinners.xml” to match “spinner.bxml”, and add the actually required <spinnerData> element.

 

b)      And/or we could change the behavior of BXMLSerializer and/or change the default spinner data (from the “Spinner()” constructor) to be a non-sequence, and/or take out the DefaultProperty in Spinner.java so that <spinnerData> is really required.

 

At the very least we should correctly document what is required to make it work so that others aren’t confused, and then we can talk about step b) and what to do there (if anything).

 

HTH,

~Roger Whitcomb


Re: Problem using wtk.content.NumericSpinnerData

Posted by Sandro Martini <sa...@gmail.com>.
Hi all,
just updated the live web page with the initial fix from Roger.

Thanks to all for the help in discovering this.
Now let's see if/what to do to make a real fix to simplify/clarify
this, if possible in 2.0.3, otherwise in 2.0.4 ...

Bye

Re: Problem using wtk.content.NumericSpinnerData

Posted by Sandro Martini <sa...@gmail.com>.
Hi,

> Indeed surrounding the NumericSpinnerData with the spinnerData tags does solve the problem.
good

> I think this one can be charted to incorrect documentation.
this should already be ok (yesterday I updated Spinners page in the
live web site), right ?

Bye

Re: Problem using wtk.content.NumericSpinnerData

Posted by Sandro Martini <sa...@gmail.com>.
Hi Roger,

> The latest code will also now work whether or not you have the "spinnerData"
> tags (with the change I made late yesterday).
Great !!

Bye

Re: Problem using wtk.content.NumericSpinnerData

Posted by Roger and Beth Whitcomb <Ro...@rbwhitcomb.com>.
The latest code will also now work whether or not you have the 
"spinnerData" tags (with the change I made late yesterday).

~Roger


Re: Problem using wtk.content.NumericSpinnerData

Posted by Mustafa Motiwala <mu...@gmail.com>.
Roger,
Indeed surrounding the NumericSpinnerData with the spinnerData tags does
solve the problem. I think this one can be charted to incorrect
documentation.
Thanks,
Mustafa.


On Thu, Jan 3, 2013 at 5:16 AM, Roger L. Whitcomb <Roger.Whitcomb@actian.com
> wrote:

> Created Pivot-887 <https://issues.apache.org/jira/browse/PIVOT-887> to
> track this.****
>
> ** **
>
> *~Roger*****
>
> ** **
>
> *From:* Roger L. Whitcomb [mailto:Roger.Whitcomb@actian.com]
> *Sent:* Wednesday, January 02, 2013 1:02 PM
> *To:* user@pivot.apache.org
> *Cc:* dev@pivot.apache.org
> *Subject:* RE: Problem using wtk.content.NumericSpinnerData****
>
> ** **
>
> Okay, I found the problem.  It is rather technical, but basically here’s
> what’s happening:****
>
> **1)      **When, in BXML, you specify a child element that starts with a
> Capital Letter, this is instantiated as an object (in this case
> NumericSpinnerData), which is then attached to the parent **somehow**
> (and therein lies the rub).  If the parent has a DefaultProperty
> annotation, then a BeanAdapter is created for the parent, and the
> DefaultProperty property is set.  For a Spinner, the DefaultProperty is
> “spinnerData” (as you would expect).****
>
> **2)      **But, inside BXMLSerializer if the value of the *existing*DefaultProperty property is a Sequence, then the child element is added via
> Sequence.add(child).  For a Spinner the initial spinner data is an empty
> ArrayList, which happens to be a Sequence, and so the NumericSpinnerData is
> added as an element of the ArrayList.  Thus the value turns into the
> “toString()” value of the NumericSpinnerData object (which is its class
> name).  So, instead of setting the NumericSpinnerData object itself as the
> spinner data, it simply adds it to the original ArrayList.****
>
> **3)      **This can be worked around by either using the <spinnerData>
> as the enclosing element in BXML or by instantiating the NumericSpinnerData
> in Java code and calling “setSpinnerData” with it.****
>
> ** **
>
> So, I can see two possible solutions:****
>
> **a)      **The Spinner tutorial code (in
> tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.bxml)
> actually has *this* code, which is why it works:****
>
> ** **
>
>         <Spinner preferredWidth="40" selectedIndex="0">****
>
>             *<spinnerData>*
>
>                 <content:NumericSpinnerData lowerBound="0" upperBound="9"
> increment="1"/>****
>
>             *</spinnerData>*
>
>         </Spinner>****
>
> ** **
>
>                 But, the associated display code in
> tutorials/www/spinners.xml only has this:****
>
>                     <Spinner preferredWidth="40" selectedIndex="0">****
>
>                         <content:NumericSpinnerData lowerBound="0"
> upperBound="9" increment="1"/>****
>
>                     </Spinner>****
>
> ** **
>
>                 Which doesn’t work because of the problem outlined above.*
> ***
>
>                 So, we could/should change the displayed example code to
> be what actually works (i.e., change “spinners.xml” to match
> “spinner.bxml”, and add the actually required <spinnerData> element.****
>
> ** **
>
> **b)      **And/or we could change the behavior of BXMLSerializer and/or
> change the default spinner data (from the “Spinner()” constructor) to be a
> non-sequence, and/or take out the DefaultProperty in Spinner.java so that
> <spinnerData> is really required.****
>
> ** **
>
> At the very least we should correctly document what is required to make it
> work so that others aren’t confused, and then we can talk about step b) and
> what to do there (if anything).****
>
> ** **
>
> HTH,****
>
> *~Roger Whitcomb*
>

RE: Problem using wtk.content.NumericSpinnerData

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Created Pivot-887 <https://issues.apache.org/jira/browse/PIVOT-887>  to track this.

 

~Roger

 

From: Roger L. Whitcomb [mailto:Roger.Whitcomb@actian.com] 
Sent: Wednesday, January 02, 2013 1:02 PM
To: user@pivot.apache.org
Cc: dev@pivot.apache.org
Subject: RE: Problem using wtk.content.NumericSpinnerData

 

Okay, I found the problem.  It is rather technical, but basically here’s what’s happening:

1)      When, in BXML, you specify a child element that starts with a Capital Letter, this is instantiated as an object (in this case NumericSpinnerData), which is then attached to the parent *somehow* (and therein lies the rub).  If the parent has a DefaultProperty annotation, then a BeanAdapter is created for the parent, and the DefaultProperty property is set.  For a Spinner, the DefaultProperty is “spinnerData” (as you would expect).

2)      But, inside BXMLSerializer if the value of the existing DefaultProperty property is a Sequence, then the child element is added via Sequence.add(child).  For a Spinner the initial spinner data is an empty ArrayList, which happens to be a Sequence, and so the NumericSpinnerData is added as an element of the ArrayList.  Thus the value turns into the “toString()” value of the NumericSpinnerData object (which is its class name).  So, instead of setting the NumericSpinnerData object itself as the spinner data, it simply adds it to the original ArrayList.

3)      This can be worked around by either using the <spinnerData> as the enclosing element in BXML or by instantiating the NumericSpinnerData in Java code and calling “setSpinnerData” with it.

 

So, I can see two possible solutions:

a)      The Spinner tutorial code (in tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.bxml) actually has this code, which is why it works:

 

        <Spinner preferredWidth="40" selectedIndex="0">

            <spinnerData>

                <content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/>

            </spinnerData>

        </Spinner>

 

                But, the associated display code in tutorials/www/spinners.xml only has this:

                    <Spinner preferredWidth="40" selectedIndex="0">

                        <content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/>

                    </Spinner>

 

                Which doesn’t work because of the problem outlined above.

                So, we could/should change the displayed example code to be what actually works (i.e., change “spinners.xml” to match “spinner.bxml”, and add the actually required <spinnerData> element.

 

b)      And/or we could change the behavior of BXMLSerializer and/or change the default spinner data (from the “Spinner()” constructor) to be a non-sequence, and/or take out the DefaultProperty in Spinner.java so that <spinnerData> is really required.

 

At the very least we should correctly document what is required to make it work so that others aren’t confused, and then we can talk about step b) and what to do there (if anything).

 

HTH,

~Roger Whitcomb


RE: Problem using wtk.content.NumericSpinnerData

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Created Pivot-887 <https://issues.apache.org/jira/browse/PIVOT-887>  to track this.

 

~Roger

 

From: Roger L. Whitcomb [mailto:Roger.Whitcomb@actian.com] 
Sent: Wednesday, January 02, 2013 1:02 PM
To: user@pivot.apache.org
Cc: dev@pivot.apache.org
Subject: RE: Problem using wtk.content.NumericSpinnerData

 

Okay, I found the problem.  It is rather technical, but basically here’s what’s happening:

1)      When, in BXML, you specify a child element that starts with a Capital Letter, this is instantiated as an object (in this case NumericSpinnerData), which is then attached to the parent *somehow* (and therein lies the rub).  If the parent has a DefaultProperty annotation, then a BeanAdapter is created for the parent, and the DefaultProperty property is set.  For a Spinner, the DefaultProperty is “spinnerData” (as you would expect).

2)      But, inside BXMLSerializer if the value of the existing DefaultProperty property is a Sequence, then the child element is added via Sequence.add(child).  For a Spinner the initial spinner data is an empty ArrayList, which happens to be a Sequence, and so the NumericSpinnerData is added as an element of the ArrayList.  Thus the value turns into the “toString()” value of the NumericSpinnerData object (which is its class name).  So, instead of setting the NumericSpinnerData object itself as the spinner data, it simply adds it to the original ArrayList.

3)      This can be worked around by either using the <spinnerData> as the enclosing element in BXML or by instantiating the NumericSpinnerData in Java code and calling “setSpinnerData” with it.

 

So, I can see two possible solutions:

a)      The Spinner tutorial code (in tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.bxml) actually has this code, which is why it works:

 

        <Spinner preferredWidth="40" selectedIndex="0">

            <spinnerData>

                <content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/>

            </spinnerData>

        </Spinner>

 

                But, the associated display code in tutorials/www/spinners.xml only has this:

                    <Spinner preferredWidth="40" selectedIndex="0">

                        <content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/>

                    </Spinner>

 

                Which doesn’t work because of the problem outlined above.

                So, we could/should change the displayed example code to be what actually works (i.e., change “spinners.xml” to match “spinner.bxml”, and add the actually required <spinnerData> element.

 

b)      And/or we could change the behavior of BXMLSerializer and/or change the default spinner data (from the “Spinner()” constructor) to be a non-sequence, and/or take out the DefaultProperty in Spinner.java so that <spinnerData> is really required.

 

At the very least we should correctly document what is required to make it work so that others aren’t confused, and then we can talk about step b) and what to do there (if anything).

 

HTH,

~Roger Whitcomb