Re: [flowscript] How to set an integer value in the FlowScript?
Christopher Oliver res1cf5x at verizon.net writes: JS Number is a double according to the specification. ScriptableWidget provides coercions that allow you to write: offset.value = 0; See the sample I recently committed. Ok, I had a look at it. woody_flow_example.js (v2) contains lines like wid.account.value = 2; wid.cowheight.value = 2; with datatype long and it seems to work. I did remote debugging and the Double is replaced by a Long in the method jsSet_value(Object value). But I'm not using the v2, but normal Woody and it seems not to work. The ScriptableWidget here has a similar logic in put() as in the mentioned jsSet_value() in v2. But setting a breakpoint inside it, it never breaks there. Is it now just a new functionality in v2 or is something broken in the current Woody ScriptableWidget? BTW, this functionality does only work for fields, but not for output widgets (it's more or less obvious from the code and I tried it with v2 sample). When thinking about it I have to ask whether we need an output widget? Isn't it just a matter of styling, but nothing for the form definition (we already have wi:field/wi:styling/@type='output'). So shouldn't we remove the output widget? Joerg
Re: [flowscript] How to set an integer value in the FlowScript?
Joerg Heinicke wrote: Christopher Oliver res1cf5x at verizon.net writes: JS Number is a double according to the specification. ScriptableWidget provides coercions that allow you to write: offset.value = 0; See the sample I recently committed. Ok, I had a look at it. woody_flow_example.js (v2) contains lines like wid.account.value = 2; wid.cowheight.value = 2; with datatype long and it seems to work. I did remote debugging and the Double is replaced by a Long in the method jsSet_value(Object value). But I'm not using the v2, but normal Woody and it seems not to work. The ScriptableWidget here has a similar logic in put() as in the mentioned jsSet_value() in v2. But setting a breakpoint inside it, it never breaks there. That's because the object provided to your event handler in your form definition is not a ScriptableWidget but rather the Java Widget. When you write offsetWidget.value = 0 you're actually calling Widget.setValue() through Rhino's Java integration Is it now just a new functionality in v2 or is something broken in the current Woody ScriptableWidget? The old ScriptableWidget has something similar but as I mentioned in my email about the new one it has other limitations that makes it unusable. BTW, this functionality does only work for fields, but not for output widgets (it's more or less obvious from the code and I tried it with v2 sample). I just added a fix for Output. Regards, Chris
Re: [flowscript] How to set an integer value in the FlowScript?
On 28.01.2004 18:21, Carlos Chávez wrote: i am think this is related with the datatype of Woody and Java the datatype in woody integer is converter in java.lang.Integer and the datatype in woody decimal is converter in java.math.BigDecimal IMO it's a problem of the FlowScript implementation/Rhino or what exactly, that defaults to Double for numbers. Can't this be handled more automatically by the FlowScript when calling Java? Christopher? Try this : offsetWidget.value = new java.lang.Integer(0); Thank you very much, this works like a charm :) Now I tried to access the error on the other end by changing the Woody definition and binding. As there is no double datatype I tried float with the following result: Tried to set value of output widget repeater.offset with an object of an incorrect type: expected class java.lang.Float, received class java.math.BigDecimal. That was not what I expected! Also this error occurs on binding load time, not when I set the value. Is this a bug?? My concern above was another one as no decimal was involved. I set the datatype and the convertor to float and the binding had a problem with it (no FlowScript widget.value = 0 involved!). If I remember correctly the binding was to an XML file and the element with its value was offset10/offset. Ok, instead of asking for further help on the last issue I had a look into the convertors myself - they are nicely short :) And I guess I found the reason for this problem: The PlainFloatConvertor returned a BigDecimal object - I guess just a copy paste problem. I will commit it now. Please confirm my observation. Joerg
Re: [flowscript] How to set an integer value in the FlowScript?
JS Number is a double according to the specification. ScriptableWidget provides coercions that allow you to write: offset.value = 0; See the sample I recently committed. Regards, Chris Joerg Heinicke wrote: On 28.01.2004 18:21, Carlos Chávez wrote: i am think this is related with the datatype of Woody and Java the datatype in woody integer is converter in java.lang.Integer and the datatype in woody decimal is converter in java.math.BigDecimal IMO it's a problem of the FlowScript implementation/Rhino or what exactly, that defaults to Double for numbers. Can't this be handled more automatically by the FlowScript when calling Java? Christopher? Try this : offsetWidget.value = new java.lang.Integer(0); Thank you very much, this works like a charm :) Now I tried to access the error on the other end by changing the Woody definition and binding. As there is no double datatype I tried float with the following result: Tried to set value of output widget repeater.offset with an object of an incorrect type: expected class java.lang.Float, received class java.math.BigDecimal. That was not what I expected! Also this error occurs on binding load time, not when I set the value. Is this a bug?? My concern above was another one as no decimal was involved. I set the datatype and the convertor to float and the binding had a problem with it (no FlowScript widget.value = 0 involved!). If I remember correctly the binding was to an XML file and the element with its value was offset10/offset. Ok, instead of asking for further help on the last issue I had a look into the convertors myself - they are nicely short :) And I guess I found the reason for this problem: The PlainFloatConvertor returned a BigDecimal object - I guess just a copy paste problem. I will commit it now. Please confirm my observation. Joerg
[flowscript] How to set an integer value in the FlowScript?
I have a little problem when setting a value of a Woody widget which is type integer in the FlowScript: Tried to set value of output widget repeater.offset with an object of an incorrect type: expected class java.lang.Integer, received class java.lang.Double. The JavaScript code is simple: offsetWidget.value = 0; I tried to enforce the datatype integer in the JavaScript by changing it to: offsetWidget.value = parseInt(0); but had no success. Now I tried to access the error on the other end by changing the Woody definition and binding. As there is no double datatype I tried float with the following result: Tried to set value of output widget repeater.offset with an object of an incorrect type: expected class java.lang.Float, received class java.math.BigDecimal. That was not what I expected! Also this error occurs on binding load time, not when I set the value. Is this a bug?? Next try was to set the datatype in Woody definition and binding to decimal, but here I'm back at the expected error message: expected class java.math.BigDecimal, received class java.lang.Double. How to fix it? Joerg
Re: [flowscript] How to set an integer value in the FlowScript?
Hi Joerg, i am think this is related with the datatype of Woody and Java the datatype in woody integer is converter in java.lang.Integer and the datatype in woody decimal is converter in java.math.BigDecimal Joerg Heinicke Escribio :-) I have a little problem when setting a value of a Woody widget which is type integer in the FlowScript: Tried to set value of output widget repeater.offset with an object of an incorrect type: expected class java.lang.Integer, received class java.lang.Double. The JavaScript code is simple: offsetWidget.value = 0; Try this : offsetWidget.setValue(new java.lang.Integer(0)); or offsetWidget.value = new java.lang.Integer(0); I tried to enforce the datatype integer in the JavaScript by changing it to: offsetWidget.value = parseInt(0); but had no success. Now I tried to access the error on the other end by changing the Woody definition and binding. As there is no double datatype I tried float with the following result: Tried to set value of output widget repeater.offset with an object of an incorrect type: expected class java.lang.Float, received class java.math.BigDecimal. That was not what I expected! Also this error occurs on binding load time, not when I set the value. Is this a bug?? Next try was to set the datatype in Woody definition and binding to decimal, but here I'm back at the expected error message: expected class java.math.BigDecimal, received class java.lang.Double. with the decimal datatype try this: repeater.offset = new java.math.BigDecimal(0); How to fix it? Joerg I hope help you. Cheers, Carlos Chávez