You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mark Lundquist <lu...@gmail.com> on 2007/07/31 22:28:53 UTC

[Flowscript] everything converted to "number" type?

Hi,

I've got some CForms widgets of <datatype base="long"/>, so I expect 
that the widget value should be a java.lang.Long, right?  I'm trying to 
do some arithmetic on these widget values in flowscript, and it seems 
like every reference to the widget value gets (a) converted to a JS 
"number" type, and (b) truncated to an integer value.  I have all kinds 
of print() scaffolding crap in my flowscript now to try to get a handle 
on this... and even, e.g.

	print (typeof someWidget.value);

prints "number" where I'd have expected it to print "object".  calling 
toString() on the value likewise prints a truncated-to-integer value, 
e.g. '3' if I input '3.5' in the form.  Please enlighten me :-)

thx,
—ml—


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Flowscript] everything converted to "number" type?

Posted by Joerg Heinicke <jo...@gmx.de>.
On 7/31/07 4:28 PM, Mark Lundquist wrote:

> (b) truncated to an integer value.

To prove this you need a number out of the integer scope.

> e.g. '3' if I input '3.5' in the form.

3.5 is for sure already truncated by the Java type conversion to Long. 
This has nothing to do with flowscript.

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Flowscript] everything converted to "number" type?

Posted by Tobia Conforto <to...@linux.it>.
Mark Lundquist wrote:
> I've got some CForms widgets of <datatype base="long"/>, so I expect
> that the widget value should be a java.lang.Long, right?

Widget's getValue() returns an Object, so that would make sense, yes.


> it seems like every reference to the widget value gets converted to a
> JS "number" type

Probably because all Java number types (including their wrapping objects
in java.lang) get converted to a JS Number, which sounds reasonable BTW.
I suppose you could find notes on the type mapping between Java and JS
on Rhino's website.  Rhino is the Javascript interpreter used by Cocoon.

Now, if it also converted java.lang.String to JS strings automatically,
it would have spared me many a headache... unfortunately that's a
conversion that Rhino seems reluctant to do.


> and truncated to an integer value.

I believe that a Java long is an integer type.


Tobia

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Flowscript] everything converted to "number" type?

Posted by Niels van Kampenhout <n....@hippo.nl>.
Mark Lundquist wrote:
> I've got some CForms widgets of <datatype base="long"/>, so I expect 
> that the widget value should be a java.lang.Long, right?  I'm trying to 
> do some arithmetic on these widget values in flowscript, and it seems 
> like every reference to the widget value gets (a) converted to a JS 
> "number" type, and (b) truncated to an integer value.  I have all kinds 
> of print() scaffolding crap in my flowscript now to try to get a handle 
> on this... and even, e.g.
> 
>     print (typeof someWidget.value);
> 
> prints "number" where I'd have expected it to print "object".  calling 
> toString() on the value likewise prints a truncated-to-integer value, 
> e.g. '3' if I input '3.5' in the form.  Please enlighten me :-)

Aren't you mixing up 'long' with 'double'? I think you need <datatype 
base="double"/> or <datatype base="decimal"/> for a value like 3.5...

See [1] for more info.

Regards
Niels

[1] http://cocoon.apache.org/2.1/userdocs/widgetconcepts/datatypes.html


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org