Tom Saddul wrote > This is what I do in TypeScript (qx-typed): > > I created a map of getters and setters taking advantage of closure > technique like this: > > // A function or method to add a SelectBox control > this.addMap(name, control, util.SqlDataType.UByte, > (s) => ui.setSelectedIndex(control, s), > // setter > () => ui.getSelectedIndex(control).toString()); // > getter > > util.SqlDataType.UByte indicates the data type conversion to be taken care > of by the server-side from a string value so all getters convert to string > so that server side will only convert from string directly. > > From this technique, getting the values in the selected controls in the > form is simply done as: > > // getPars() > names.forEach(e => { > for (var i = 0; i < count; i++) { > var par = this.pars[i]; > if (par.Name === e) { > par.Value = this.controls[e].getter(); // > note the getter execution here! > pars.push(par); > break; > } > } > }); > > The JSON request is sent like this: > > util.postJson<util.RequestNewRecord, number>(this, > "newrecord", { > TableName: this.entry.tableName, > Pars: this.entry.getPars() // getPars > retrieves needed values from form > }, (r) => { > // r is a number returned from server which is Id of the > new record created in table > }); > > This technique simplifies retrieval of ready-to-send data with a single > call to getPars(). > > ADDED LATER: > > By the way, here are my SelectBox functions: > > export function getSelectedIndex(control: qx.ui.form.SelectBox): > number { > var selected = control.getSelection(); > > if (selected.length > 0) > return control.getChildren().indexOf(selected[0]); > else > return 0; > } > > export function setSelectedIndex(control: qx.ui.form.SelectBox, index: > any) { > control.setSelection([ > <qx.ui.core.Widget> > control.getChildren()[str.toInt(index)]]); > }
Why don't you create your own binding code? If you do this using the regular qooxdoo controller to bind the model to the view, you'll get the same result, with less code: playground <http://demo.qooxdoo.org/4.1/playground/#%7B%22code%22%3A%22%252F%252F%2520Create%2520a%2520model%2520for%2520the%2520combo%250Avar%2520comboModel%2520%253D%2520qx.data.marshal.Json.createModel%28%255B%255D%29%253B%250A%252F%252F%2520Create%2520a%2520combo%2520and%2520controller%2520using%2520the%2520combo%2520model%250Avar%2520combo%2520%253D%2520new%2520qx.ui.form.ComboBox%28%29%253B%250Avar%2520comboCtrl%2520%253D%2520new%2520qx.data.controller.List%28comboModel%252C%2520combo%29%253B%250A%250A%252F%252F%2520Create%2520a%2520textfield%250Avar%2520textf%2520%253D%2520new%2520qx.ui.form.TextField%28%29%253B%250A%250A%252F%252F%2520Create%2520a%2520model%2520for%2520the%2520select%250Avar%2520selectModel%2520%253D%2520qx.data.marshal.Json.createModel%28%255B%250A%2520%2520%257B%250A%2520%2520%2520%2520label%253A%2520%27Select%25201%27%252C%2520data%253A%2520%271%27%2520%250A%2520%2520%257D%252C%250A%2520%2520%257B%250A%2520%2520%2520%2520label%253A%2520%27Select%25202%27%252C%2520dat a%253A%2520%272%27%250A%2520%2520%257D%250A%255D%29%253B%250A%252F%252F%2520Create%2520a%2520selectbox%2520and%2520controller%2520using%2520the%2520select%2520model%250Avar%2520select%2520%253D%2520new%2520qx.ui.form.SelectBox%28%29%253B%250Avar%2520selectCtrl%2520%253D%2520new%2520qx.data.controller.List%28null%252C%2520select%29%253B%250A%252F%252F%2520Map%2520the%2520model%2520to%2520the%2520select%2520box%250AselectCtrl.setDelegate%28%257B%250A%2520%2520bindItem%253A%2520%28ctrl%252C%2520item%252C%2520indx%29%2520%253D%253E%250A%2520%2520%257B%250A%2520%2520%2520%2520ctrl.bindProperty%28%2522label%2522%252C%2520%2522label%2522%252C%2520null%252C%2520item%252C%2520indx%29%253B%250A%2520%2520%2520%2520ctrl.bindProperty%28%2522data%2522%252C%2520%2522model%2522%252C%2520null%252C%2520item%252C%2520indx%29%253B%250A%2520%2520%257D%250A%257D%29%253B%250AselectCtrl.setModel%28selectModel%29%253B%250A%250A%252F%252F%2520Create%2520a%2520model%2520for%2520the%2520form%250Avar%2520formMo del%2520%253D%2520qx.data.marshal.Json.createModel%28%257B%250A%2520%2520text%253A%2520null%252C%250A%2520%2520combo%253A%2520null%252C%250A%2520%2520select%253A%2520null%250A%257D%29%253B%250A%252F%252F%2520Create%2520a%2520form%2520to%2520hold%2520the%2520textfield%2520and%2520combo%250A%252F%252F%2520and%2520a%2520controller%2520using%2520the%2520form%2520model%250Avar%2520form%2520%253D%2520new%2520qx.ui.form.Form%28%29%253B%250Aform.add%28textf%252C%2520%2522Text%2522%252C%2520null%252C%2520%27text%27%29%253B%250Aform.add%28combo%252C%2520%2522Combo%2522%252C%2520null%252C%2520%27combo%27%29%253B%250Aform.add%28select%252C%2520%2522Select%2522%252C%2520null%252C%2520%27select%27%29%253B%250Avar%2520frmCtrl%2520%253D%2520new%2520qx.data.controller.Form%28formModel%252C%2520form%29%253B%250A%250A%252F%252F%2520Create%2520a%2520renderer%2520for%2520the%2520form%2520%250A%252F%252F%2520and%2520add%2520the%2520form%2520to%2520the%2520window%250A%252F%252F%2520using%2520a%2520vbox%25 20layout%250Avar%2520rend%2520%253D%2520new%2520qx.ui.form.renderer.Single%28form%29%253B%250Avar%2520wnd%2520%253D%2520new%2520qx.ui.window.Window%28%29%253B%250Awnd.setLayout%28new%2520qx.ui.layout.VBox%28%29%29%253B%250Awnd.add%28rend%29%253B%250A%250A%252F%252F%2520Show%2520the%2520window%250Awnd.show%28%29%253B%250A%250A%252F%252F%2520Add%2520items%2520to%2520the%2520comboModel%250AcomboModel.push%28%27Test%27%29%253B%250AcomboModel.push%28%27Test2%27%29%253B%250A%250A%252F%252F%2520Get%2520the%2520model%2520after%2520the%2520user%2520changed%2520%250A%252F%252F%2520the%2520view%252C%2520reflecting%2520these%2520changes%250Aqx.util.Serializer.toJson%28formModel%29%253B%22%2C%20%22mode%22%3A%22ria%22%7D> -- View this message in context: http://qooxdoo.678.n2.nabble.com/list-controller-does-not-update-list-tp7586693p7586701.html Sent from the qooxdoo mailing list archive at Nabble.com. ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet _______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel