[FlexJS] DataBinding Problem

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[FlexJS] DataBinding Problem

yishayw
Trying to debug accordion I ran into a data binding issue.

TitleBarView.mxml has this line:

 <js:Label id="titleLabel" text="{ITitleBarModel(model).title}" className="TitleBarTitle" >

But if I change the model to a tbModel where tbModel.title == "hi" I will not the label text is empty instead of it being 'hi'.

In other words, data binding only works if the host stays the same.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

yishayw
Example app [1]

[1] https://paste.apache.org/hdOl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

piotrz
Hi Yishay,

Please raise jira with above information and I will look into that.

Thanks,
Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

yishayw
You got it [1]. Thanks Piotr.

[1] https://issues.apache.org/jira/browse/FLEX-35320
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

piotrz
Yishay,

Try to make one more test. Add to this example bead ApplicationDataBinding and let me know if something changed.

Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

piotrz
In reply to this post by yishayw
Hi Yishay,

I did spent some time on this but cannot find so far why binding is not working after model change. I think it should be.

There is SimpleBinding class involve in all of this. Array _bindings [1] seems to contains everything what needed, but maybe we should react somewhere on "modelChanged" event.

But where ? Changing model on the fly should reflected into refreshing in somehow binding.

The only thing which I noticed that when I'm assigning new model [2], it's being added as bead but the old one is not removed. Basically when you do this one:

pv.titleBar.model = new TitleBarModel(); - You will have many models in _beads Array.

Not sure if it is ok.

[1] https://paste.apache.org/SsO4
[2] https://paste.apache.org/Efit

Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

Alex Harui-2
SimpleBinding is tuned for simple cases.  It doesn't expect the object it
is watching to change, just its properties.

GenericBinding will watch for that, but the DataBinding implementation has
to choose GenericBinding.

It should be ok for objects to share models as long as it is done "early"
in the lifecycle.  If it used to work, it was probably because the model
was shared before binding was evaluated.  I would recommend finding a way
to delay the evaluation of the binding until after the model is shared.

I can look into it this evening.

-Alex

On 6/5/17, 2:28 PM, "piotrz" <[hidden email]> wrote:

>Hi Yishay,
>
>I did spent some time on this but cannot find so far why binding is not
>working after model change. I think it should be.
>
>There is SimpleBinding class involve in all of this. Array _bindings [1]
>seems to contains everything what needed, but maybe we should react
>somewhere on "modelChanged" event.
>
>But where ? Changing model on the fly should reflected into refreshing in
>somehow binding.
>
>The only thing which I noticed that when I'm assigning new model [2], it's
>being added as bead but the old one is not removed. Basically when you do
>this one:
>
>pv.titleBar.model = new TitleBarModel(); - You will have many models in
>_beads Array.
>
>Not sure if it is ok.
>
>[1]
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpaste.apa
>che.org%2FSsO4&data=02%7C01%7C%7Cf670dbe4aa2141a0704b08d4ac5bf2c3%7Cfa7b1b
>5a7b34438794aed2c178decee1%7C0%7C0%7C636322958296810241&sdata=ybbRW2qgPwSF
>TLec0pUskBiLkcurDjnISYQWm0JvLqs%3D&reserved=0
>[2]
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpaste.apa
>che.org%2FEfit&data=02%7C01%7C%7Cf670dbe4aa2141a0704b08d4ac5bf2c3%7Cfa7b1b
>5a7b34438794aed2c178decee1%7C0%7C0%7C636322958296810241&sdata=cG2ZqQnin9%2
>Blgd7i5vVKTHwqsyQdUR47tRYA5vGeSuM%3D&reserved=0
>
>Piotr
>
>
>
>-----
>Apache Flex PMC
>[hidden email]
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-DataBinding-Problem-tp62073p6
>2123.html&data=02%7C01%7C%7Cf670dbe4aa2141a0704b08d4ac5bf2c3%7Cfa7b1b5a7b3
>4438794aed2c178decee1%7C0%7C0%7C636322958296810241&sdata=ZSPovQAOFZ22PBxLk
>nt8qAvw4hfqhS6YGqT2oSM3gb0%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

yishayw
It's actually MXMLBeadViewDataBinding. The simplest solution may be to avoid using binding in TitleBarView and explicitly listen to TitleBar's "modelChanged" event and TitleBarModel's "titleChange" event. But any other solution is fine by me.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

piotrz
Alex,

I was thinking about that more and more. I think the way how MXMLBeadViewDataBinding decided what binding has been chosen in case of TitleBarView is ok. - We probably shouldn't change anything in that matter.

Exchange model - That's more global thing - cause if we allow for this in case of TitleBar/Panel the other components need to be also able to do this.

Yishay,

It's class related to binding for example MXMLBeadViewDataBinding - has complex condition which decide what kind of binding actually should be used: Generic, SimpleDataBinding or ConstanBinding.

Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

Alex Harui-2
In reply to this post by yishayw
I have local changes that fixes Binding in Accordion by changing the
lifecycle of the underlying Panel that AccordionItemRenderer subclasses.
I'll push them before I shut down for the day.  I want to try to fix the
TitleBar height issue on JS first.

The reasoning is that ItemRenderers are supposed to have a different
lifecycle.  Normally, Binding is run as soon as the component is added as
a child.  But in renderers, Binding and layout isn't worth running at that
point in the lifecycle because just about everything is dependent on the
"data" property.  So, the changes you'll see is that the
AccordionItemRendererView overrides PanelView's completeSetup() and
doesn't add the TitleBar or layout the renderer until data is set, which
is after the model gets shared.

FLEX-35320 is theoretically a feature request.  The current Binding
implementation doesn't support changing the "host", but a fancier, fatter
and slower Binding implementation can.  PAYG and all that.

Thanks,
-Alex

On 6/5/17, 11:12 PM, "yishayw" <[hidden email]> wrote:

>It's actually MXMLBeadViewDataBinding. The simplest solution may be to
>avoid
>using binding in TitleBarView and explicitly listen to TitleBar's
>"modelChanged" event and TitleBarModel's "titleChange" event. But any
>other
>solution is fine by me.
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-DataBinding-Problem-tp62073p6
>2133.html&data=02%7C01%7C%7Cb938b4dde0754478487808d4aca52e82%7Cfa7b1b5a7b3
>4438794aed2c178decee1%7C0%7C0%7C636323272830510197&sdata=iBHXLtdzCt6HDZbJZ
>1eEaUL139K5F%2Bm7fEo9hAG5FbU%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] DataBinding Problem

piotrz
I think we can make it as feature request and Yishay probably need to handle "modelChanged" event on your own to have such code working on the fly.

What do you think Yishay ?

Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [FlexJS] DataBinding Problem

yishayw
It looks like Alex is modifying Panel to fix the problem in Accordion. I’m good with that.

From: piotrz<mailto:[hidden email]>
Sent: Tuesday, June 6, 2017 10:10 AM
To: [hidden email]<mailto:[hidden email]>
Subject: Re: [FlexJS] DataBinding Problem

I think we can make it as feature request and Yishay probably need to handle
"modelChanged" event on your own to have such code working on the fly.

What do you think Yishay ?

Piotr



-----
Apache Flex PMC
[hidden email]
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-DataBinding-Problem-tp62073p62141.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [FlexJS] DataBinding Problem

piotrz
It will work for you, but your raised bug is more general thing. Almost each component has model - what if I would like to change that model on the fly ?

Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Loading...