Home » Eclipse Projects » Remote Application Platform (RAP) » strange behaviour in custom widget when passing "float value strings" to client
strange behaviour in custom widget when passing "float value strings" to client [message #114047] |
Sun, 30 November 2008 09:18  |
Eclipse User |
|
|
|
Hi RAP folks,
currently I try to develop my first RAP custom widget and everything
went positive so far. Now I try to pass "float value strings" to the
client side. With float value strings I mean something like
"100.0,200.0". The string will be parsed/splitted on client side.
See my strippend example below:
// **********
// LCA
public void renderChanges(final Widget widget) throws IOException {
...
writer.set( PROP, JS_PROP, "100.0,200.0" );
...
}
// Widget.js
...
properties : {
prop : {
check: "String",
init : "",
apply : "_apply"
},
...
_apply : function(value) {
alert( value );
...
},
// **********
Testing this I get a javascript popup notifying "100". But that's not
the expected value. If I modify the writer.set() method and client side
_apply() method to:
// **********
// LCA
public void renderChanges(final Widget widget) throws IOException {
...
writer.set( PROP, JS_PROP, "abc100.0,200.0" );
...
}
// Widget.js
...
properties : {
prop : {
check: "String",
init : "",
apply : "_apply"
},
...
_apply : function(value) {
value = value.substring( 3 );
alert( value );
...
},
// **********
With this work arraound I get passed the correct string value to the
client side and the javascript pops up with "100.0,200.0".
Das anybody know this strange behaviour? Something that I didn't fully
understand yet?
Regards, Lars
--
Lars Martin
Coach & Consultant
Telefon: +49 (0) 341 / 231-0183-402
Telefax: +49 (0) 341 / 231-0183-411
Mobil: +49 (0) 151 / 1739-6732 (neu!)
http://www.itemis.de
lars.martin@itemis.de
https://www.xing.com/profile/Lars_Martin2
itemis AG
Ludwig-Erhard-Straße 51
04103 Leipzig
Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Dr. Burkhard Igel(Vors.), Stephan Grollmann, Michael Neuhaus
|
|
|
Re: strange behaviour in custom widget when passing "float value strings" to client [message #114089 is a reply to message #114047] |
Sun, 30 November 2008 18:23   |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Lars,
did you try a "regular" Javascript function like
setProp : function( value ) {
alert( value );
}
Does that change anything?
HTH
Rüdiger
Lars Martin wrote:
> Hi RAP folks,
>
> currently I try to develop my first RAP custom widget and everything
> went positive so far. Now I try to pass "float value strings" to the
> client side. With float value strings I mean something like
> "100.0,200.0". The string will be parsed/splitted on client side.
> See my strippend example below:
>
> // **********
> // LCA
>
> public void renderChanges(final Widget widget) throws IOException {
> ...
> writer.set( PROP, JS_PROP, "100.0,200.0" );
> ...
> }
>
> // Widget.js
>
> ...
> properties : {
> prop : {
> check: "String",
> init : "",
> apply : "_apply"
> },
> ...
> _apply : function(value) {
> alert( value );
> ...
> },
>
> // **********
>
> Testing this I get a javascript popup notifying "100". But that's not
> the expected value. If I modify the writer.set() method and client side
> _apply() method to:
>
> // **********
> // LCA
>
> public void renderChanges(final Widget widget) throws IOException {
> ...
> writer.set( PROP, JS_PROP, "abc100.0,200.0" );
> ...
> }
>
> // Widget.js
>
> ...
> properties : {
> prop : {
> check: "String",
> init : "",
> apply : "_apply"
> },
> ...
> _apply : function(value) {
> value = value.substring( 3 );
> alert( value );
> ...
> },
>
> // **********
>
> With this work arraound I get passed the correct string value to the
> client side and the javascript pops up with "100.0,200.0".
>
> Das anybody know this strange behaviour? Something that I didn't fully
> understand yet?
>
> Regards, Lars
>
|
|
|
Re: strange behaviour in custom widget when passing "float value strings" to client [message #114330 is a reply to message #114089] |
Wed, 03 December 2008 17:27  |
Eclipse User |
|
|
|
Hi Rüdiger,
I'm not sure if I understand you. But without defining a property "prop"
and simply providing the corresponding setter "setProp" I exactly get
the same result. But I've a solution:
writer.set( PROP, JS_PROP, obj.toString() )
This will pass the correct value to the java script side. Here "obj" is
a simple class with to members "float x" and "float y" and the
overwritten "toString()" simply returns "<x>,<y>". Without adding
"toString()" to "obj" in writer.set(), the second (y) value is getting
lost. I dont understand why but I can live with this pragmatic solution.
The second thing I've learned from you: I don't have to define a
property for each value that gets passed from the java side. A "setProp"
is sufficient here.
Regards, Lars
Rüdiger Herrmann wrote:
> Lars,
>
> did you try a "regular" Javascript function like
> setProp : function( value ) {
> alert( value );
> }
> Does that change anything?
>
> HTH
> Rüdiger
>
> Lars Martin wrote:
>> Hi RAP folks,
>>
>> currently I try to develop my first RAP custom widget and everything
>> went positive so far. Now I try to pass "float value strings" to the
>> client side. With float value strings I mean something like
>> "100.0,200.0". The string will be parsed/splitted on client side.
>> See my strippend example below:
>>
>> // **********
>> // LCA
>>
>> public void renderChanges(final Widget widget) throws IOException {
>> ...
>> writer.set( PROP, JS_PROP, "100.0,200.0" );
>> ...
>> }
>>
>> // Widget.js
>>
>> ...
>> properties : {
>> prop : {
>> check: "String",
>> init : "",
>> apply : "_apply"
>> },
>> ...
>> _apply : function(value) {
>> alert( value );
>> ...
>> },
>>
>> // **********
>>
>> Testing this I get a javascript popup notifying "100". But that's not
>> the expected value. If I modify the writer.set() method and client
>> side _apply() method to:
>>
>> // **********
>> // LCA
>>
>> public void renderChanges(final Widget widget) throws IOException {
>> ...
>> writer.set( PROP, JS_PROP, "abc100.0,200.0" );
>> ...
>> }
>>
>> // Widget.js
>>
>> ...
>> properties : {
>> prop : {
>> check: "String",
>> init : "",
>> apply : "_apply"
>> },
>> ...
>> _apply : function(value) {
>> value = value.substring( 3 );
>> alert( value );
>> ...
>> },
>>
>> // **********
>>
>> With this work arraound I get passed the correct string value to the
>> client side and the javascript pops up with "100.0,200.0".
>>
>> Das anybody know this strange behaviour? Something that I didn't fully
>> understand yet?
>>
>> Regards, Lars
>>
|
|
|
Goto Forum:
Current Time: Tue May 13 19:04:36 EDT 2025
Powered by FUDForum. Page generated in 0.03154 seconds
|