Hi Martin, thanks for making life easier when working with Single Selection and data binding. However, I am still not happy with the result, especially when working with forms. For example, see this code in the playground (http://demo.qooxdoo.org/devel/playground/)
// select box var data = [{"value":"article","icon":"icon\/16\/actions\/document-new.png","label":"Article"},{"value":"book","icon":"icon\/16\/actions\/document-new.png","label":"Book (Monograph)"},{"value":"booklet","icon":"icon\/16\/actions\/document-new.png","label":"Booklet"},{"value":"collection","icon":"icon\/16\/actions\/document-new.png","label":"Book (Edited)"},{"value":"conference","icon":"icon\/16\/actions\/document-new.png","label":"Conference Paper"},{"value":"inbook","icon":"icon\/16\/actions\/document-new.png","label":"Book Chapter"},{"value":"incollection","icon":"icon\/16\/actions\/document-new.png","label":"Chapter in Edited Book"},{"value":"inproceedings","icon":"icon\/16\/actions\/document-new.png","label":"Paper in Conference Proceedings"},{"value":"journal","icon":"icon\/16\/actions\/document-new.png","label":"Journal Issue"},{"value":"manual","icon":"icon\/16\/actions\/document-new.png","label":"Handbook"},{"value":"mastersthesis","icon":"icon\/16\/actions\/document-new.png","label":"Master's Thesis"},{"value":"misc","icon":"icon\/16\/actions\/document-new.png","label":"Miscellaneous"},{"value":"phdthesis","icon":"icon\/16\/actions\/document-new.png","label":"Ph.D. Thesis"},{"value":"proceedings","icon":"icon\/16\/actions\/document-new.png","label":"Conference Proceedings"},{"value":"techreport","icon":"icon\/16\/actions\/document-new.png","label":"Report\/Working Paper"},{"value":"unpublished","icon":"icon\/16\/actions\/document-new.png","label":"Unpublished Manuscript"}]; var model = qx.data.marshal.Json.createModel(data,true); var selectBox = new qx.ui.form.SelectBox(); var controller = new qx.data.controller.List( null, selectBox, "label" ); controller.setIconPath("icon"); controller.setModel(model); // form var form = new qx.ui.form.Form(); form.add(selectBox,"Type",null,"type"); form.add(new qx.ui.form.TextField(),"Title",null,"title"); // render form this.getRoot().add(form.createView()); // form controller var formController = new qx.data.controller.Form(null,form); // model that would normally be supplied by a remote store var formModel = qx.data.marshal.Json.createModel({ 'title' : "Blah!", 'type' : "booklet" },true); // this correctly sets the textfield but not the selectbox formController.setModel(formModel); How would I go about when populating a form that contains SelectBoxes (or RadioGroups) from remote model data? The bidirectional binding of "modelSelection[0]" of the SelectBox list model data to the target property in the form model does not help, because the form model property does not contain suitable model data. Where do I have to set up the binding so that the selection of the SelectBox is bound to a value supplied in the form data? This was all much easier when there was still a "value" property in the single selection widgets.... Thanks, Christian MartinWittemann wrote: > > Hi, > > thanks for sharing your thoughts. We agree that the current way of binding > the modelSelection is not suitable for the demands qooxdoo has. Thats why > we opened up the bug. The proposed mixin is just a workarount and not the > solution which is in the framework in the end. > I already fix the issue and the solution would look like this: > > controller.addTarget(selectbox, "modelSelection[0]", "modelProperty", > true); > > We are back to a one line of code and that already works in the trunk. I > guess that is something you like to see, right? > > If you want to stay on your 0.8.3 release i can send you the patches to > apply to have only that new feature. > > Best, > Martin > > > > Jean-Noël Rivasseau wrote: >> >> Hi, >> >> I spent a lot of time understanding the APIs change and such. Here are my >> remarks: >> >> * Currently it has become awfully complex and ugly to bind a SelectBox or >> a >> RadioButtonGroup to a simple property value. This is because you have to >> use >> *two* controllers to bind, since in one controller you must use the >> "modelSelection" property as target, and in the other, you must use >> "selection" as an event to listen on. You cannot use a simple >> bidirectional >> controller, and on top of that, you must add some converters. >> >> So it is clearly for me a regression, what was a one liner has become 10 >> lines of ugly boilerplate code. I agree that maybe an API change was >> needed, >> but if it makes stuff more complex instead of easier, this is not good. >> >> 2) The proposed change (that is linked in the bug) really does not seem >> ideal to me, because it forces you to define models as objects that have >> a >> "value" property so that it works. In most cases I guess what people will >> want is just a simple String acting as the value, thus the model will be >> the >> value. The Mixin that is posted in the bug *should* act like this, eg >> test >> if we are dealing wit a simple string as the model, and if yes, use that >> as >> the value. This is mandatory IMHO to keep things going smoothly... >> >> 3) Is the Mixin linked in the bug available in trunk now? The bug is not >> marked as fixed yet. How can I use this mixin? Is trunk stable enough >> right >> now? I am wary of moving away from an official release, but this API >> change >> without the mixin is so painful that I probably will. >> >> Jean-Noel >> >> >> On Wed, Sep 16, 2009 at 4:54 PM, MartinWittemann >> <martin.wittem...@1und1.de>wrote: >> >>> >>> Hello >>> >>> sure this is still possible but a bit complicated in the release >>> version. >>> Take a look at the following email to see how it works with a radio >>> group, >>> which is basically the same as a selectbox. >>> >>> http://n2.nabble.com/RadioButtonGroup-and-ModelSelection-td3573156.html#a3573156 >>> >>> But we are aware of thie and that its a bit complicated so we opend up a >>> bug >>> report to make it more comfortable. >>> http://bugzilla.qooxdoo.org/show_bug.cgi?id=2778 >>> As you can see, it is already fixed and can now be bound line one line >>> again. >>> >>> Regards, >>> Martin >>> >>> >>> >>> Jean-Noël Rivasseau wrote: >>> > >>> > Hello, when upgrading our app to 0.8.3 I encounter the following >>> problem: >>> > >>> > I previously used data binding for a simple property related to a >>> > SelectBox. >>> > It was ok like that: >>> > >>> > controller.addTarget(widget.rightSelect, "value", >>> "rightMode", >>> > true); >>> > >>> > But now "value" is deprecated for SelectBox and I cannot find an easy >>> > equivalent. There is now a special Selection controller but it looks >>> like >>> > it >>> > is intended to work with arrays; and here my property is a simple >>> String. >>> > I >>> > changed the ListItem values properties to model instead, but there is >>> no >>> > setModel() method on SelectBox. >>> > >>> > I tried >>> > controller.addTarget(widget.rightSelect, "modelSelection", >>> > "rightMode", true); >>> > >>> > but that wont work with data binding as there is no >>> "changeModelSelection" >>> > event... >>> > >>> > So I am stuck. value worked very well before, I understand that you >>> > changed >>> > the API (although let me say that this caused hundred of deprecations >>> > warnings in our app; basically everything we were doing with form >>> widgets >>> > had to be upgraded...), but what's the correct way to deal with this >>> now? >>> > It's a simple case, bind a single selection listItem to a property, so >>> > that >>> > should be possible. >>> > >>> > Martin? >>> > >>> > Jean-Noel >>> > >>> > >>> ------------------------------------------------------------------------------ >>> > Come build with us! The BlackBerry® Developer Conference in SF, CA >>> > is the only developer event you need to attend this year. Jumpstart >>> your >>> > developing skills, take BlackBerry mobile applications to market and >>> stay >>> >>> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry® Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9-12, 2009. Register >> now! >> http://p.sf.net/sfu/devconf >> _______________________________________________ >> qooxdoo-devel mailing list >> qooxdoo-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel >> >> > > -- View this message in context: http://n2.nabble.com/How-to-use-data-binding-for-a-SelectBox-which-is-intended-for-single-selection-tp3656721p3680720.html Sent from the Q&A (solved) mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel