Hello guys,

The issue is the following. I made a form with some textfields these are
later bounded to a model which can have a value or can be null. I would
expect that the behaviour of the controller would be something like clearing
the textfields or other form items when the model is null because its bound
to something wihich can be a value like proper filled model or a null value
which also is a value!

If a property is null of the model which is bound, the form will clear the
value of the textfield which is nice :).
When the model is null the controller will do nothing.
When a model contains another model you can bind to the values in it, when
this model is also null the controller will again do nothing with the
textfields which were bound to the model inside.

Do I have to reset the textfields manually by listening to an change event?

Thanks in advance,
Erol Demircan

Here is some code for the playground.

var person1 = { 
                name:"NameVal 1", 
                surname:"SurnameVal 1", 
                address:{
                  street : "StreetVal 1",
                  number : "10"
                }
              };
              
var person2 = { 
                name:"NameVal 2", 
                surname:null, 
                address:null
              };

var model1 = qx.data.marshal.Json.createModel(person1);
var model2 = qx.data.marshal.Json.createModel(person2);


var form = new qx.ui.form.Form();
form.addGroupHeader("Person");
var name = new qx.ui.form.TextField("name");
form.add(name, "Name", null, "name");
var surname = new qx.ui.form.TextField();
form.add(surname, "Surname", null, "surname");
var street = new qx.ui.form.TextField();
form.add(street, "Street", null, "address.street");
var number = new qx.ui.form.TextField();
form.add(number, "Number", null, "address.number");

var button1 = new qx.ui.form.Button("Set Person1");
var button2 = new qx.ui.form.Button("Set Person2");
var button3 = new qx.ui.form.Button("Clear?");

var controller = new qx.data.controller.Form(null, form);
controller.setModel(null);

button1.addListener("execute",function(){
  controller.setModel(model1);
},this);

button2.addListener("execute",function(){
  controller.setModel(model2);
},this);

button3.addListener("execute",function(){
  controller.setModel(null);
},this);

this.getRoot().add(new qx.ui.form.renderer.Single(form), {left: 10, top:
10});
this.getRoot().add(button1, {left: 10, top: 150});
this.getRoot().add(button2, {left: 100, top: 150});
this.getRoot().add(button3, {left: 190, top: 150});






--
View this message in context: 
http://qooxdoo.678.n2.nabble.com/Why-doesn-t-a-form-controller-reset-the-fields-when-the-model-is-null-tp7203270p7203270.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to