开发者

qx.ui.form.Spinner.setValue() question

开发者 https://www.devze.com 2023-01-28 22:37 出处:网络
I got a qx.ui.form.Spinner object and I am setting the initial value from an XML file. The value is unfortunately returned as a string, which leads to the following confusing error in Firebug:

I got a qx.ui.form.Spinner object and I am setting the initial value from an XML file. The value is unfortunately returned as a string, which leads to the following confusing error in Firebug:

Error in property value of class qx.ui开发者_开发知识库.form.Spinner in method setValue with incoming value '3': Is invalid!

Running this sample in the Playground doesn't produce any error, but the spinner is not being set:

// Create a button
var button1 = new qx.ui.form.Button("First Button", "icon/22/apps/internet-web-browser.png");

// Document is the application root
var doc = this.getRoot();

var spinner = new qx.ui.form.Spinner(1, 1, 60);

doc.add(spinner);

// Add button to document at fixed coordinates
doc.add(button1,
{
  left : 100,
  top  : 50
});

// Add an event listener
button1.addListener("execute", function(e) {
  spinner.setValue("3");
});

So my questions are:

  • should the string value be working? So far it seemed to be seldom a problem when number are actually string.
  • should the Playground give an error?


To answer your questions:

  • No, the string value will not work. Try using the parseInt() function to convert the string into an integer.

  • Actually the Playground is giving a problem, but the exception is not handled by the Playground, Try adding a try .. catch and you will see the exact same errormessage you already know.

    try { spinner.setValue("3"); } catch (e) { alert(e); }


Thanks. I already uses parseInt() to get it worked and I submitted a bug report: http://bugzilla.qooxdoo.org/show_bug.cgi?id=4457


I daresay the Playground should at least log the error in its "Log" window. You might want to consider opening a bug for this.

0

精彩评论

暂无评论...
验证码 换一张
取 消