Hi,

thanks for the code but again, it took me some time go get to the bottom of the 
problem because its way too much code. The first thing I realized was, you are 
not using a placeholder at all.
So I guess you speak of that initial text you added.

Thats easy to explain. On one hand, you are creating the textfield containing 
the default text which is the thing you expected to be in the textfield. On the 
other hand, you create a model which contains a "firstname" field holding null. 
The time you connect these two values using the controller, on of them has to 
win and thats the value in the model. So creating your model with that initial 
value will fix the whole thing. But using a real placeholder could save some 
headache for the user in this case [1].

Best,
Martin

[1] http://demo.qooxdoo.org/devel/demobrowser/index.html#showcase~Form.html

Am 01.09.2010 um 11:38 schrieb Stefan Andersson:

var pfn1TF = this.__pfn1TF = new 
qx.ui.form.TextField(this<http://this.tr>.<http://this.tr>tr<http://this.tr>("A 
full firstname"));
pfn1TF.setRequired(true);
pfn1TF.setWidth(200);

var pfn1L = this.__pfn1L = new 
qx.ui.basic.Label(this<http://this.tr>.<http://this.tr>tr<http://this.tr>("Firstname"));
pfn1L.setBuddy(pfn1TF);
pfn1L.setAlignY("middle");


var pfn2TF = this.__pfn2TF = new 
qx.ui.form.TextField(this<http://this.tr>.<http://this.tr>tr<http://this.tr>("A 
full firstname"));
pfn2TF.setRequired(true);
pfn2TF.setWidth(200);

var pfn2L = this.__pfn2L = new 
qx.ui.basic.Label(this<http://this.tr>.<http://this.tr>tr<http://this.tr>("Firstname"));
pfn2L.setBuddy(pfn2TF);
pfn2L.setAlignY("middle");

var validator = this.__validator = new qx.ui.form.validation.Manager();
validator.add(this.__pfn2TF, null);

var controller = new qx.data.controller.Object();
controller.addTarget(this.__pfn2TF, "value", "firstname", true);

var skeleton = {
  firstname : null
};

this.__model = qx.data.marshal.Json.createModel(skeleton, true);

controller.setModel(this.__model);

this.__model.addListener("changeBubble", function(e) {
  validator.validate();
}, this);

// invoke the inital validate
validator.validate();

var root = this.getRoot();

root.setLayout(new qx.ui.layout.Grid(2, 2));

root.add(pfn1L, {row: 0, column: 0});
root.add(pfn1TF, {row: 0, column: 1});

root.add(pfn2L, {row: 1, column: 0});
root.add(pfn2TF, {row: 1, column: 1});


-----------------------

Two examples. One with binding and one without.

Stefan
<ATT00001..txt><ATT00002..txt>

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to