pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roger L. Whitcomb" <Roger.Whitc...@actian.com>
Subject RE: Problem using wtk.content.NumericSpinnerData
Date Wed, 02 Jan 2013 21:16:31 GMT
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

Mime
View raw message