Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » LCA class for custom widgets - JSON?
LCA class for custom widgets - JSON? [message #45273] Tue, 04 September 2007 20:29 Go to next message
Eclipse UserFriend
Originally posted by: giuliapo.gmail.com

Hi there.
As I have said here, I'm developing a custom widget. I have some doubts
regarding the LCA class and it's set method.

Well, it is something like this: I can pass a simple int from Java to
Javascript, strings, Integer objects, array of integer and even an array
of Object. My question is: why can't I pass some more complex object to
javascript? Example: if I try to pass an array of objects that has a
Point object in each position, nothing happens.

In other words: is RAP using JSON (for instance) to pass objects to
javascript? Or is RAP only wrapping simple objects like String, Integer,
Double...?

Because I think that I will have to do use the LCA class to pass a
string to javascript, but I will encapsulate my objects in a JSON
object, serializing them. On the javascript side, I will receive the
String and eval it.

What do you think? Is my approach correct or am Im repeating something
that RAP is already doing?


Hope you understood what I'm traying to explain.

Best regards,
Bruno.
Re: LCA class for custom widgets - JSON? [message #45559 is a reply to message #45273] Thu, 06 September 2007 19:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Hi Bruno,

it is a bit difficult to answer this without knowing much about your
use-case. Maybe you could provide some more concrete details about what
you would like to achieve.
The general idea behind RAP is to keep the JavaScript layer as thin and
'dumb' as possible. Following this rule, we haven't yet had the need to
exchange complex data structures. That said, it doesn't mean your
approach must be wrong - I just don't know much about it.

Please also see my comments blow.

Cheers,
Rüdiger

Bruno Vieira wrote:
> Hi there.
> As I have said here, I'm developing a custom widget. I have some doubts
> regarding the LCA class and it's set method.
>
> Well, it is something like this: I can pass a simple int from Java to
> Javascript, strings, Integer objects, array of integer and even an array
> of Object. My question is: why can't I pass some more complex object to
> javascript? Example: if I try to pass an array of objects that has a
> Point object in each position, nothing happens.

You are right, with the JSWriter you can only pass simple types from
Java to JavaScript. As we could also 'serialize' well-known types like
Point, there simple was no need to do so yet. With arbitrary Objects
there would the problem arise which fields or properties should be
'serialized' and then *how* should they be 'serialized'.

>
> In other words: is RAP using JSON (for instance) to pass objects to
> javascript? Or is RAP only wrapping simple objects like String, Integer,
> Double...?

We decided against JSON as this approach wasn't flexible enough for our
needs.
RAP sends JavaScript 'static' function or 'method' calls to the client.
All these calls have simple types as their parameters or are
parameterless.
If you are using Firefox and have FireBug installed, take a look at the
'Response' in the console tab to get an idea how this looks like.
The whole response gets executed in a single windows.eval() call.

>
> Because I think that I will have to do use the LCA class to pass a
> string to javascript, but I will encapsulate my objects in a JSON
> object, serializing them. On the javascript side, I will receive the
> String and eval it.

The LCA is the right place to mediate between client and server. The way
from server to client is handled in the renderXXX methods.
rednerInitialization() is called once in the life cycle of a widget
within the same request it was created. renderChanges is called with
every request. Finally, renderDipose is called with the request that
destroyed the widget by calling its dispose() method.
To read request parameters that carry the changes made on the client
side, the readData method comes into play.

>
> What do you think? Is my approach correct or am Im repeating something
> that RAP is already doing?
>
>
> Hope you understood what I'm traying to explain.
>
> Best regards,
> Bruno.
Re: LCA class for custom widgets - JSON? [message #47795 is a reply to message #45559] Wed, 19 September 2007 01:42 Go to previous message
Eclipse UserFriend
Originally posted by: just4lists.nospammail.net

Hi Rüdiger.

The use case is a custom widget for charts using the EJSChart
(http://www.ejschart.com/) javascript lib. Our idea would be to bind some
"simple" data structure (mainly chart properties and series data) to the
component.

> We decided against JSON as this approach wasn't flexible enough for our
> needs.

It would be possible to keep the actual approach. I believe (but could be
wrong) that using the JSON-lib (http://json-lib.sourceforge.net/) in the
"else" clause of the JSWriter would do the trick whithout breaking the
actual code and providing extended support (for free) for other data
structures (beans, maps, collections, java arrays and XML).

As RAP newbies, we loosed some time trying to understand where our data was
beeing "discarded" (not "translated" into the client side). I think this
could be a nice "feature" helping also future newbies and keeping expert
developers also away from the JSWriter.

Best regards,

Joel Oliveira

"Rüdiger Herrmann" <rherrmann@innoopract.com> escreveu na mensagem
news:fbpkvr$k77$1@build.eclipse.org...
> Hi Bruno,
>
> it is a bit difficult to answer this without knowing much about your
> use-case. Maybe you could provide some more concrete details about what
> you would like to achieve.
> The general idea behind RAP is to keep the JavaScript layer as thin and
> 'dumb' as possible. Following this rule, we haven't yet had the need to
> exchange complex data structures. That said, it doesn't mean your approach
> must be wrong - I just don't know much about it.
>
> Please also see my comments blow.
>
> Cheers,
> Rüdiger
>
> Bruno Vieira wrote:
>> Hi there.
>> As I have said here, I'm developing a custom widget. I have some doubts
>> regarding the LCA class and it's set method.
>>
>> Well, it is something like this: I can pass a simple int from Java to
>> Javascript, strings, Integer objects, array of integer and even an array
>> of Object. My question is: why can't I pass some more complex object to
>> javascript? Example: if I try to pass an array of objects that has a
>> Point object in each position, nothing happens.
>
> You are right, with the JSWriter you can only pass simple types from Java
> to JavaScript. As we could also 'serialize' well-known types like Point,
> there simple was no need to do so yet. With arbitrary Objects there would
> the problem arise which fields or properties should be 'serialized' and
> then *how* should they be 'serialized'.
>
>>
>> In other words: is RAP using JSON (for instance) to pass objects to
>> javascript? Or is RAP only wrapping simple objects like String, Integer,
>> Double...?
>
> We decided against JSON as this approach wasn't flexible enough for our
> needs.
> RAP sends JavaScript 'static' function or 'method' calls to the client.
> All these calls have simple types as their parameters or are
> parameterless.
> If you are using Firefox and have FireBug installed, take a look at the
> 'Response' in the console tab to get an idea how this looks like.
> The whole response gets executed in a single windows.eval() call.
>
>>
>> Because I think that I will have to do use the LCA class to pass a string
>> to javascript, but I will encapsulate my objects in a JSON object,
>> serializing them. On the javascript side, I will receive the String and
>> eval it.
>
> The LCA is the right place to mediate between client and server. The way
> from server to client is handled in the renderXXX methods.
> rednerInitialization() is called once in the life cycle of a widget within
> the same request it was created. renderChanges is called with every
> request. Finally, renderDipose is called with the request that destroyed
> the widget by calling its dispose() method.
> To read request parameters that carry the changes made on the client side,
> the readData method comes into play.
>
>>
>> What do you think? Is my approach correct or am Im repeating something
>> that RAP is already doing?
>>
>>
>> Hope you understood what I'm traying to explain.
>>
>> Best regards,
>> Bruno.
Previous Topic:custom widget with external JS
Next Topic:cell editor
Goto Forum:
  


Current Time: Tue Jul 23 05:52:07 GMT 2024

Powered by FUDForum. Page generated in 0.04016 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top