Data binding questions

View: New views
6 Messages — Rating Filter:   Alert me  

Data binding questions

by Bugzilla from elvanor@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have two questions, mainly about the list controller.

1) First, does the removeAllBindings() work for data arrays that are bound to a UI element such as a selectbox?

The following code for example throws an error:

            var listController = new qx.data.controller.List(this.getFonts(), object.fontList);
           
            this.getFonts().removeAllBindings();
            listController.setTarget(null);
            this.getFonts().removeAll();

It fails on the last line with: this.getTarget() is null
This is due to the binding, that somehow was not removed by

            this.getFonts().removeAllBindings();

Is that a bug? Or is there a different way to remove bindings for a list?

2) I have an object that has a List (a data array). How can I set data binding for the list (via a list controller), to a SelectBox for instance, but which would also work when the object change? Eg, I want that the list be always up to date with respect to the current object list. Either the object or the list may change.

I have no idea on how to do that. With simple object controller, deep binding works (eg, any change in the property chain will work), but I am not sure how to achieve that with a list.

Thanks,
Jean-Noel

PS: after a bit of porting and adjustment, let me congratulate the whole team about Qx 0.8.3. It is a big step forward and not only for the bug fixing: I like the new APIs much better (more consistent).

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Re: Data binding questions

by Martin Wittemann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello Jean-Noël,

1) Your code looks something wrong to me. I don't get what you are trying to
do. But removeAllBindings using a list controller should not be called
because the controller handles all the bindings and is responsible for the
whole life cycle of them.
If you just want to remove all fonts, why take care of the binding. This
should be the problem of the controller. ;) So just use the last line and
the list will be empty.

2) You can achieve that by using two bindings. Lets say object A has the
data array stored in property a. Now you can set up a single value binding
like this:
A.bind("a", listController, "model");
The list controller takes care of the given model and the single value
binding takes care of setting the model. Thats the most elegant way to do it
i think.

Regards,
Martin


Jean-Noël Rivasseau wrote:

>
> Hi,
>
> I have two questions, mainly about the list controller.
>
> 1) First, does the removeAllBindings() work for data arrays that are bound
> to a UI element such as a selectbox?
>
> The following code for example throws an error:
>
>             var listController = new
> qx.data.controller.List(this.getFonts(), object.fontList);
>
>             this.getFonts().removeAllBindings();
>             listController.setTarget(null);
>             this.getFonts().removeAll();
>
> It fails on the last line with: this.getTarget() is null
> This is due to the binding, that somehow was not removed by
>
>             this.getFonts().removeAllBindings();
>
> Is that a bug? Or is there a different way to remove bindings for a list?
>
> 2) I have an object that has a List (a data array). How can I set data
> binding for the list (via a list controller), to a SelectBox for instance,
> but which would also work when the object change? Eg, I want that the list
> be always up to date with respect to the current object list. Either the
> object or the list may change.
>
> I have no idea on how to do that. With simple object controller, deep
> binding works (eg, any change in the property chain will work), but I am
> not
> sure how to achieve that with a list.
>
> Thanks,
> Jean-Noel
>
> PS: after a bit of porting and adjustment, let me congratulate the whole
> team about Qx 0.8.3. It is a big step forward and not only for the bug
> fixing: I like the new APIs much better (more consistent).
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> qooxdoo-devel mailing list
> qooxdoo-devel@...
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

--
View this message in context: http://n2.nabble.com/Data-binding-questions-tp3954836p3957973.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Re: Data binding questions

by Bugzilla from elvanor@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

My code looks stupid of course, it was just an example. What I actually want is to remove all the bindings for a given object (the actual reason I want to do that is because I am writing tests in the testRunner, and I need to remove the bindings in the tearDown().

If the only way is to use the controller... how can I achieve it? The controller does not seem to have any methods to remove the bindings.

About 2), I will try as soon as possible - is it possible to use a controller for the single value binding? I somehow prefer controllers.

On Fri, Nov 6, 2009 at 11:40 AM, MartinWittemann <martin.wittemann@...> wrote:

Hello Jean-Noël,

1) Your code looks something wrong to me. I don't get what you are trying to
do. But removeAllBindings using a list controller should not be called
because the controller handles all the bindings and is responsible for the
whole life cycle of them.
If you just want to remove all fonts, why take care of the binding. This
should be the problem of the controller. ;) So just use the last line and
the list will be empty.

2) You can achieve that by using two bindings. Lets say object A has the
data array stored in property a. Now you can set up a single value binding
like this:
A.bind("a", listController, "model");
The list controller takes care of the given model and the single value
binding takes care of setting the model. Thats the most elegant way to do it
i think.

Regards,
Martin


Jean-Noël Rivasseau wrote:
>
> Hi,
>
> I have two questions, mainly about the list controller.
>
> 1) First, does the removeAllBindings() work for data arrays that are bound
> to a UI element such as a selectbox?
>
> The following code for example throws an error:
>
>             var listController = new
> qx.data.controller.List(this.getFonts(), object.fontList);
>
>             this.getFonts().removeAllBindings();
>             listController.setTarget(null);
>             this.getFonts().removeAll();
>
> It fails on the last line with: this.getTarget() is null
> This is due to the binding, that somehow was not removed by
>
>             this.getFonts().removeAllBindings();
>
> Is that a bug? Or is there a different way to remove bindings for a list?
>
> 2) I have an object that has a List (a data array). How can I set data
> binding for the list (via a list controller), to a SelectBox for instance,
> but which would also work when the object change? Eg, I want that the list
> be always up to date with respect to the current object list. Either the
> object or the list may change.
>
> I have no idea on how to do that. With simple object controller, deep
> binding works (eg, any change in the property chain will work), but I am
> not
> sure how to achieve that with a list.
>
> Thanks,
> Jean-Noel
>
> PS: after a bit of porting and adjustment, let me congratulate the whole
> team about Qx 0.8.3. It is a big step forward and not only for the bug
> fixing: I like the new APIs much better (more consistent).
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> qooxdoo-devel mailing list
> qooxdoo-devel@...
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

--
View this message in context: http://n2.nabble.com/Data-binding-questions-tp3954836p3957973.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Re: Data binding questions

by Bugzilla from elvanor@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Quick update: for the 2), the suggestion works perfectly, even with a controller! Thanks. Data binding in Qx is uber cool :)

On Fri, Nov 6, 2009 at 4:08 PM, Jean-Noël Rivasseau <elvanor@...> wrote:
Hi,

My code looks stupid of course, it was just an example. What I actually want is to remove all the bindings for a given object (the actual reason I want to do that is because I am writing tests in the testRunner, and I need to remove the bindings in the tearDown().

If the only way is to use the controller... how can I achieve it? The controller does not seem to have any methods to remove the bindings.

About 2), I will try as soon as possible - is it possible to use a controller for the single value binding? I somehow prefer controllers.


On Fri, Nov 6, 2009 at 11:40 AM, MartinWittemann <martin.wittemann@...> wrote:

Hello Jean-Noël,

1) Your code looks something wrong to me. I don't get what you are trying to
do. But removeAllBindings using a list controller should not be called
because the controller handles all the bindings and is responsible for the
whole life cycle of them.
If you just want to remove all fonts, why take care of the binding. This
should be the problem of the controller. ;) So just use the last line and
the list will be empty.

2) You can achieve that by using two bindings. Lets say object A has the
data array stored in property a. Now you can set up a single value binding
like this:
A.bind("a", listController, "model");
The list controller takes care of the given model and the single value
binding takes care of setting the model. Thats the most elegant way to do it
i think.

Regards,
Martin


Jean-Noël Rivasseau wrote:
>
> Hi,
>
> I have two questions, mainly about the list controller.
>
> 1) First, does the removeAllBindings() work for data arrays that are bound
> to a UI element such as a selectbox?
>
> The following code for example throws an error:
>
>             var listController = new
> qx.data.controller.List(this.getFonts(), object.fontList);
>
>             this.getFonts().removeAllBindings();
>             listController.setTarget(null);
>             this.getFonts().removeAll();
>
> It fails on the last line with: this.getTarget() is null
> This is due to the binding, that somehow was not removed by
>
>             this.getFonts().removeAllBindings();
>
> Is that a bug? Or is there a different way to remove bindings for a list?
>
> 2) I have an object that has a List (a data array). How can I set data
> binding for the list (via a list controller), to a SelectBox for instance,
> but which would also work when the object change? Eg, I want that the list
> be always up to date with respect to the current object list. Either the
> object or the list may change.
>
> I have no idea on how to do that. With simple object controller, deep
> binding works (eg, any change in the property chain will work), but I am
> not
> sure how to achieve that with a list.
>
> Thanks,
> Jean-Noel
>
> PS: after a bit of porting and adjustment, let me congratulate the whole
> team about Qx 0.8.3. It is a big step forward and not only for the bug
> fixing: I like the new APIs much better (more consistent).
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> qooxdoo-devel mailing list
> qooxdoo-devel@...
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

--
View this message in context: http://n2.nabble.com/Data-binding-questions-tp3954836p3957973.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Re: Data binding questions

by Bugzilla from elvanor@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Martin

Could you please answer this if possible? I really need the answer...

On Fri, Nov 6, 2009 at 4:08 PM, Jean-Noël Rivasseau <elvanor@...> wrote:
Hi,

My code looks stupid of course, it was just an example. What I actually want is to remove all the bindings for a given object (the actual reason I want to do that is because I am writing tests in the testRunner, and I need to remove the bindings in the tearDown().

If the only way is to use the controller... how can I achieve it? The controller does not seem to have any methods to remove the bindings.

About 2), I will try as soon as possible - is it possible to use a controller for the single value binding? I somehow prefer controllers.


On Fri, Nov 6, 2009 at 11:40 AM, MartinWittemann <martin.wittemann@...> wrote:

Hello Jean-Noël,

1) Your code looks something wrong to me. I don't get what you are trying to
do. But removeAllBindings using a list controller should not be called
because the controller handles all the bindings and is responsible for the
whole life cycle of them.
If you just want to remove all fonts, why take care of the binding. This
should be the problem of the controller. ;) So just use the last line and
the list will be empty.

2) You can achieve that by using two bindings. Lets say object A has the
data array stored in property a. Now you can set up a single value binding
like this:
A.bind("a", listController, "model");
The list controller takes care of the given model and the single value
binding takes care of setting the model. Thats the most elegant way to do it
i think.

Regards,
Martin


Jean-Noël Rivasseau wrote:
>
> Hi,
>
> I have two questions, mainly about the list controller.
>
> 1) First, does the removeAllBindings() work for data arrays that are bound
> to a UI element such as a selectbox?
>
> The following code for example throws an error:
>
>             var listController = new
> qx.data.controller.List(this.getFonts(), object.fontList);
>
>             this.getFonts().removeAllBindings();
>             listController.setTarget(null);
>             this.getFonts().removeAll();
>
> It fails on the last line with: this.getTarget() is null
> This is due to the binding, that somehow was not removed by
>
>             this.getFonts().removeAllBindings();
>
> Is that a bug? Or is there a different way to remove bindings for a list?
>
> 2) I have an object that has a List (a data array). How can I set data
> binding for the list (via a list controller), to a SelectBox for instance,
> but which would also work when the object change? Eg, I want that the list
> be always up to date with respect to the current object list. Either the
> object or the list may change.
>
> I have no idea on how to do that. With simple object controller, deep
> binding works (eg, any change in the property chain will work), but I am
> not
> sure how to achieve that with a list.
>
> Thanks,
> Jean-Noel
>
> PS: after a bit of porting and adjustment, let me congratulate the whole
> team about Qx 0.8.3. It is a big step forward and not only for the bug
> fixing: I like the new APIs much better (more consistent).
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> qooxdoo-devel mailing list
> qooxdoo-devel@...
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

--
View this message in context: http://n2.nabble.com/Data-binding-questions-tp3954836p3957973.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Re: Data binding questions

by Martin Wittemann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello Jean-Noël,

sorry for the late answer. Part of the qooxdoo team including me has been on
the JSConf in Berlin over the weekend so we had our weekend on monday and
thursday. Thats why i havent answered jet.

The controller does not have any method for modifying bindings because the
idea of using a controller is not to know anything about the bindings. So I
tried to keep the whole single value binding stuff out of the sight of the
controller user.
I think the code you are looking for would look something like this:

controller.setModel(null);
controller.setTarget(null);

That should remove all bindings from the model and the target including all
listener.

Best,
Martin



Jean-Noël Rivasseau wrote:

>
> Hi Martin
>
> Could you please answer this if possible? I really need the answer...
>
> On Fri, Nov 6, 2009 at 4:08 PM, Jean-Noël Rivasseau
> <elvanor@...>wrote:
>
>> Hi,
>>
>> My code looks stupid of course, it was just an example. What I actually
>> want is to remove all the bindings for a given object (the actual reason
>> I
>> want to do that is because I am writing tests in the testRunner, and I
>> need
>> to remove the bindings in the tearDown().
>>
>> If the only way is to use the controller... how can I achieve it? The
>> controller does not seem to have any methods to remove the bindings.
>>
>> About 2), I will try as soon as possible - is it possible to use a
>> controller for the single value binding? I somehow prefer controllers.
>>
>>
>> On Fri, Nov 6, 2009 at 11:40 AM, MartinWittemann <
>> martin.wittemann@...> wrote:
>>
>>>
>>> Hello Jean-Noël,
>>>
>>> 1) Your code looks something wrong to me. I don't get what you are
>>> trying
>>> to
>>> do. But removeAllBindings using a list controller should not be called
>>> because the controller handles all the bindings and is responsible for
>>> the
>>> whole life cycle of them.
>>> If you just want to remove all fonts, why take care of the binding. This
>>> should be the problem of the controller. ;) So just use the last line
>>> and
>>> the list will be empty.
>>>
>>> 2) You can achieve that by using two bindings. Lets say object A has the
>>> data array stored in property a. Now you can set up a single value
>>> binding
>>> like this:
>>> A.bind("a", listController, "model");
>>> The list controller takes care of the given model and the single value
>>> binding takes care of setting the model. Thats the most elegant way to
>>> do
>>> it
>>> i think.
>>>
>>> Regards,
>>> Martin
>>>
>>>
>>> Jean-Noël Rivasseau wrote:
>>> >
>>> > Hi,
>>> >
>>> > I have two questions, mainly about the list controller.
>>> >
>>> > 1) First, does the removeAllBindings() work for data arrays that are
>>> bound
>>> > to a UI element such as a selectbox?
>>> >
>>> > The following code for example throws an error:
>>> >
>>> >             var listController = new
>>> > qx.data.controller.List(this.getFonts(), object.fontList);
>>> >
>>> >             this.getFonts().removeAllBindings();
>>> >             listController.setTarget(null);
>>> >             this.getFonts().removeAll();
>>> >
>>> > It fails on the last line with: this.getTarget() is null
>>> > This is due to the binding, that somehow was not removed by
>>> >
>>> >             this.getFonts().removeAllBindings();
>>> >
>>> > Is that a bug? Or is there a different way to remove bindings for a
>>> list?
>>> >
>>> > 2) I have an object that has a List (a data array). How can I set data
>>> > binding for the list (via a list controller), to a SelectBox for
>>> instance,
>>> > but which would also work when the object change? Eg, I want that the
>>> list
>>> > be always up to date with respect to the current object list. Either
>>> the
>>> > object or the list may change.
>>> >
>>> > I have no idea on how to do that. With simple object controller, deep
>>> > binding works (eg, any change in the property chain will work), but I
>>> am
>>> > not
>>> > sure how to achieve that with a list.
>>> >
>>> > Thanks,
>>> > Jean-Noel
>>> >
>>> > PS: after a bit of porting and adjustment, let me congratulate the
>>> whole
>>> > team about Qx 0.8.3. It is a big step forward and not only for the bug
>>> > fixing: I like the new APIs much better (more consistent).
>>> >
>>> >
>>> ------------------------------------------------------------------------------
>>> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> > 30-Day
>>> > trial. Simplify your report design, integration and deployment - and
>>> focus
>>> > on
>>> > what you do best, core application coding. Discover what's new with
>>> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> > _______________________________________________
>>> > qooxdoo-devel mailing list
>>> > qooxdoo-devel@...
>>> > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://n2.nabble.com/Data-binding-questions-tp3954836p3957973.html
>>> Sent from the qooxdoo mailing list archive at Nabble.com.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and
>>> focus
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> qooxdoo-devel mailing list
>>> qooxdoo-devel@...
>>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>>
>>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> qooxdoo-devel mailing list
> qooxdoo-devel@...
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

--
View this message in context: http://n2.nabble.com/Data-binding-questions-tp3954836p3984874.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel