这是另一个做事稍有不同的例子。查看嵌入的 cmets。
qx.Class.define("xxx.view.XxxView",
{
extend : qx.ui.container.Composite,
properties : {
CaseID : {
check : 'String',
event : "changeCaseID",
init : '000000000'
}
},
members : {
_CaseIDLabel : null
},
construct : function()
{
// We need to call the superclass constructor.
// In this case, we also provide a layout for this container.
this.base(arguments, new qx.ui.layout.VBox());
// Here we instantiate a Label with initial text, but that text
// will be immediately overwritten so we'll never see it
this._CaseIDLabel = new qx.ui.basic.Label("initial");
this.add(this._CaseIDLabel);
// We can bind to our own property, as done here. Note, though,
// that this doesn't use the being-initialized value in the property
// without explicit instruction... so we then force-initialize that
// property.
this.bind('changeCaseID', this._CaseIDLabel, 'value');
this.initCaseID();
}
});
// Instantiate one of these xxxView objects, and place it on the page
var xxxView = new xxx.view.XxxView();
this.getRoot().add(xxxView, { left : 10, top : 200 } );
// Show how the property value can change later, and update the label
setTimeout(
function()
{
xxxView.setCaseID('Hello world!');
},
2000);
可以看到在操场上运行:http://tinyurl.com/vml8bru