Hello rob,
thats an interessting approach you are taking the data binding for. I hadn't
that in mind during designing the binding features but event better that it
can be used fur such things too.
You problem seems to be a easy one. As you said right, you are binding a int
value to a textfield. As long as the textfield can only take string values,
the int value can not be handled and an exception will be thrown. Usually
the data binding can convert int to string (well, not too hard) if the
target is a property. But value on the textfield is no property even if it
looks like one. That means, the data binding can not get the desired target
data type and without that information, an automatic conversion is not
possible.
But supplying a converter is easy because you are already using the options
map for the binding which is named bitrateValidation in you example. Add
another key to it called converter and add the converte function:
var bitrateValidation = {
converter : function (data) {
return data + "";
},
onSetOk : function() {
bitrateField.resetShadow();
alert(parent.getBitRate());
},
onSetFail : function(e) {
validationTextField.setShadow(validationDecorator);
alert("FAIL");
}
};
That should do the job. :)
Best,
Martin
Elsner, Robert wrote:
>
> Using qooxdoo 0.8.2 I'm trying to bind a property of a class to a text
> field.
>
> properties : {
> bitRate: {init: 0, check: "Number"}
> },
>
> ...
>
> var bitrateField = new
> qx.ui.form.TextField(this.getBitRate().toString());
> var validationDecorator = new
> qx.ui.decoration.Single(1, "solid",
> "red");
> var bitrateValidation = {
> onSetOk : function() {
> bitrateField.resetShadow();
> alert(parent.getBitRate());
> },
> onSetFail : function(e) {
>
> validationTextField.setShadow(validationDecorator);
> alert("FAIL");
> }
> };
> bitrateField.bind("input", this, "bitRate",
> bitrateValidation);
>
> However, when I type an invalid input ("A" for instance) all I get is an
> exception instead of the value.
>
> I know 0.8.3 has some very cool features, but I want to stick with 0.8.2
> for now... so does anyone have any ideas?
>
> Thanks in advance,
> rob
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
--
View this message in context:
http://n2.nabble.com/Data-binding-a-number-property-tp3544256p3551839.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel