You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Carlos Rovira <ca...@apache.org> on 2018/09/19 16:13:32 UTC

Binding issue (Re: [royale-asjs] branch develop updated: ComboBox selectedItem example)

Hi,

this example work if I but this label

<j:Label text="selectedItem: {(cmb2.selectedItem as IconListVO).label}"/>

in the current position (below the HGroup that holds the ComboBox)

If I put the Label before the HGroup the binding is undefined.

This seems a bug in the binding system, and seems to be related to order of
declaration.

Or I could be missing something here?

Thanks!

Carlos







El mié., 19 sept. 2018 a las 17:24, <ca...@apache.org> escribió:

> This is an automated email from the ASF dual-hosted git repository.
>
> carlosrovira pushed a commit to branch develop
> in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
>
>
> The following commit(s) were added to refs/heads/develop by this push:
>      new 1c7843b  ComboBox selectedItem example
> 1c7843b is described below
>
> commit 1c7843b524de55e8cb6e1c0d1b7fa142f78a639e
> Author: Carlos Rovira <ca...@apache.org>
> AuthorDate: Wed Sep 19 17:24:23 2018 +0200
>
>     ComboBox selectedItem example
> ---
>  .../src/main/royale/ComboBoxPlayGround.mxml         | 21
> ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git
> a/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
> b/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
> index 614d268..d8930a3 100644
> --- a/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
> +++ b/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
> @@ -25,6 +25,8 @@ limitations under the License.
>
>         <fx:Script>
>                 <![CDATA[
> +                       import vos.IconListVO;
> +
>              private function
> watchmenComboBoxSelectedItem(event:Event):void {
>                                 watchmenComboBoxResult.html =
> "<strong>ComboBox selectedItem:</strong> " + event.target.selectedItem;
>              }
> @@ -144,19 +146,32 @@ limitations under the License.
>                 </j:GridCell>
>
>         </j:Grid>
> +
>         <j:Grid gap="true" itemsVerticalAlign="itemsSameHeight">
> -
>                 <j:GridCell desktopNumerator="1" desktopDenominator="1"
>                                         tabletNumerator="1"
> tabletDenominator="1"
>                                         phoneNumerator="1"
> phoneDenominator="1">
> -
>                         <j:Card>
>                                 <html:H3 text="Jewel ComboBox
> selectedIndex: {cmb1.selectedIndex}"/>
>
>                                 <j:HGroup gap="3"
> itemsVerticalAlign="itemsCentered">
>                                         <j:ComboBox id="cmb1"
> labelField="label" dataProvider="{listModel.avengers}" selectedIndex="2"/>
>                                 </j:HGroup>
> -
> +                       </j:Card>
> +               </j:GridCell>
> +       </j:Grid>
> +
> +       <j:Grid gap="true" itemsVerticalAlign="itemsSameHeight">
> +               <j:GridCell desktopNumerator="1" desktopDenominator="1"
> +                                       tabletNumerator="1"
> tabletDenominator="1"
> +                                       phoneNumerator="1"
> phoneDenominator="1">
> +                       <j:Card>
> +                               <html:H3 text="Jewel ComboBox
> selectedItem"/>
> +
> +                               <j:HGroup gap="3"
> itemsVerticalAlign="itemsCentered">
> +                                       <j:ComboBox id="cmb2"
> labelField="label" dataProvider="{listModel.avengers}"
> selectedItem="{listModel.avengers.getItemAt(3)}" />
> +                               </j:HGroup>
> +                               <j:Label text="selectedItem:
> {(cmb2.selectedItem as IconListVO).label}"/>
>                         </j:Card>
>                 </j:GridCell>
>         </j:Grid>
>
>

-- 
Carlos Rovira
http://about.me/carlosrovira

Re: Binding issue (Re: [royale-asjs] branch develop updated: ComboBox selectedItem example)

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Yes, Carlos, there could be bugs in Binding or anywhere in Royale.  Debug into it and see what is going on.

Binding works pretty much the same way as it did in Flex.  The property being watched must have an initial value or dispatch an event when that value changes.  Metadata indicates which events to listen for.

Sometimes the event metadata is missing or wrong, or the expression isn't typed correctly (this one looks ok) and the compiler generates a warning saying that changes to some property will not be detected.

Sometimes, the change event isn't fired.

Binding in Flex was much slower and heavier because it was more redundant.  It tried several times at startup to evaluate all binding expressions.  In Royale, we are trying to find many fewer points in the lifecycle (hopefully only one) to evaluate initial values in binding expressions.  In theory, all changes after that point should generate a change event.  In ItemRenderers, that point is after the data property is set.  In Containers, I think it is done on initBindings.

Order of declaration could affect order of evaluation.  But then a change event "should" fire as expressions get evaluated.

HTH,
-Alex

On 9/19/18, 9:13 AM, "Carlos Rovira" <ca...@apache.org> wrote:

    Hi,
    
    this example work if I but this label
    
    <j:Label text="selectedItem: {(cmb2.selectedItem as IconListVO).label}"/>
    
    in the current position (below the HGroup that holds the ComboBox)
    
    If I put the Label before the HGroup the binding is undefined.
    
    This seems a bug in the binding system, and seems to be related to order of
    declaration.
    
    Or I could be missing something here?
    
    Thanks!
    
    Carlos
    
    
    
    
    
    
    
    El mié., 19 sept. 2018 a las 17:24, <ca...@apache.org> escribió:
    
    > This is an automated email from the ASF dual-hosted git repository.
    >
    > carlosrovira pushed a commit to branch develop
    > in repository https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitbox.apache.org%2Frepos%2Fasf%2Froyale-asjs.git&amp;data=02%7C01%7Caharui%40adobe.com%7C59f077e8f1d742126f3d08d61e4ae141%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636729704285897246&amp;sdata=7H40Vgub%2FUpBf2QBj5v3RNAtxsCOo1LNaCtFv1D1lys%3D&amp;reserved=0
    >
    >
    > The following commit(s) were added to refs/heads/develop by this push:
    >      new 1c7843b  ComboBox selectedItem example
    > 1c7843b is described below
    >
    > commit 1c7843b524de55e8cb6e1c0d1b7fa142f78a639e
    > Author: Carlos Rovira <ca...@apache.org>
    > AuthorDate: Wed Sep 19 17:24:23 2018 +0200
    >
    >     ComboBox selectedItem example
    > ---
    >  .../src/main/royale/ComboBoxPlayGround.mxml         | 21
    > ++++++++++++++++++---
    >  1 file changed, 18 insertions(+), 3 deletions(-)
    >
    > diff --git
    > a/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
    > b/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
    > index 614d268..d8930a3 100644
    > --- a/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
    > +++ b/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
    > @@ -25,6 +25,8 @@ limitations under the License.
    >
    >         <fx:Script>
    >                 <![CDATA[
    > +                       import vos.IconListVO;
    > +
    >              private function
    > watchmenComboBoxSelectedItem(event:Event):void {
    >                                 watchmenComboBoxResult.html =
    > "<strong>ComboBox selectedItem:</strong> " + event.target.selectedItem;
    >              }
    > @@ -144,19 +146,32 @@ limitations under the License.
    >                 </j:GridCell>
    >
    >         </j:Grid>
    > +
    >         <j:Grid gap="true" itemsVerticalAlign="itemsSameHeight">
    > -
    >                 <j:GridCell desktopNumerator="1" desktopDenominator="1"
    >                                         tabletNumerator="1"
    > tabletDenominator="1"
    >                                         phoneNumerator="1"
    > phoneDenominator="1">
    > -
    >                         <j:Card>
    >                                 <html:H3 text="Jewel ComboBox
    > selectedIndex: {cmb1.selectedIndex}"/>
    >
    >                                 <j:HGroup gap="3"
    > itemsVerticalAlign="itemsCentered">
    >                                         <j:ComboBox id="cmb1"
    > labelField="label" dataProvider="{listModel.avengers}" selectedIndex="2"/>
    >                                 </j:HGroup>
    > -
    > +                       </j:Card>
    > +               </j:GridCell>
    > +       </j:Grid>
    > +
    > +       <j:Grid gap="true" itemsVerticalAlign="itemsSameHeight">
    > +               <j:GridCell desktopNumerator="1" desktopDenominator="1"
    > +                                       tabletNumerator="1"
    > tabletDenominator="1"
    > +                                       phoneNumerator="1"
    > phoneDenominator="1">
    > +                       <j:Card>
    > +                               <html:H3 text="Jewel ComboBox
    > selectedItem"/>
    > +
    > +                               <j:HGroup gap="3"
    > itemsVerticalAlign="itemsCentered">
    > +                                       <j:ComboBox id="cmb2"
    > labelField="label" dataProvider="{listModel.avengers}"
    > selectedItem="{listModel.avengers.getItemAt(3)}" />
    > +                               </j:HGroup>
    > +                               <j:Label text="selectedItem:
    > {(cmb2.selectedItem as IconListVO).label}"/>
    >                         </j:Card>
    >                 </j:GridCell>
    >         </j:Grid>
    >
    >
    
    -- 
    Carlos Rovira
    https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7C59f077e8f1d742126f3d08d61e4ae141%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636729704285897246&amp;sdata=bxN9F8V5D8ryhuXRk67NODlKXIIokAWAefEopc6dBZ4%3D&amp;reserved=0