Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Read data from custom widget.
Read data from custom widget. [message #122413] Tue, 24 February 2009 12:43 Go to next message
Eclipse UserFriend
Originally posted by: haglund86.hotmail.com

Hello.
I have created a custom widget which is built on qooxdoo and consists of
two lists. I can populate one of the lists from the java code, but how
do I read data from the list to the RAP application?

I have looked at the google maps example and they are using the function
readData in the LCA-file. But the example was to complex for me to fully
understand.

So my question is how do I read a variable from the javascript?
I would appreciate if someone could post an simple example of a custom
widget that reads data from the qooxdoo code.
Re: Read data from custom widget. [message #122443 is a reply to message #122413] Tue, 24 February 2009 14:22 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Erik,
here is a simple code that put in the request the value of your variable
"this.myParam" and send the request to the server:
------------
var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
var req = org.eclipse.swt.Request.getInstance();
var id = widgetManager.findIdByWidget( this );
req.addParameter( id + ".myParam", this.myParam );
req.send();
-------------
In your LCA#readData, you can read this parameter from the request:
-------------
String value = WidgetLCAUtil.readPropertyValue( widget, "myParam" );
if( value != null ) {
// do something if the parameter is found
}

Hope that this will help.
Best,
Ivan

Erik Haglund wrote:
> Hello.
> I have created a custom widget which is built on qooxdoo and consists
> of two lists. I can populate one of the lists from the java code, but
> how do I read data from the list to the RAP application?
>
> I have looked at the google maps example and they are using the
> function readData in the LCA-file. But the example was to complex for
> me to fully understand.
>
> So my question is how do I read a variable from the javascript?
> I would appreciate if someone could post an simple example of a custom
> widget that reads data from the qooxdoo code.
Re: Read data from custom widget. [message #122463 is a reply to message #122443] Tue, 24 February 2009 16:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: haglund86.hotmail.com

Hi thank you for the example code.
However I have a problem related to this topic.

I wan't to be able to call my qooxdoo function and read my variable at a
given time.
So how do I call a function in qooxdoo from the LCA?

/Erik
Ivan Furnadjiev skrev:
> Hi Erik,
> here is a simple code that put in the request the value of your variable
> "this.myParam" and send the request to the server:
> ------------
> var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
> var req = org.eclipse.swt.Request.getInstance();
> var id = widgetManager.findIdByWidget( this ); req.addParameter(
> id + ".myParam", this.myParam );
> req.send();
> -------------
> In your LCA#readData, you can read this parameter from the request:
> -------------
> String value = WidgetLCAUtil.readPropertyValue( widget, "myParam" );
> if( value != null ) {
> // do something if the parameter is found }
>
> Hope that this will help.
> Best,
> Ivan
>
> Erik Haglund wrote:
>> Hello.
>> I have created a custom widget which is built on qooxdoo and consists
>> of two lists. I can populate one of the lists from the java code, but
>> how do I read data from the list to the RAP application?
>>
>> I have looked at the google maps example and they are using the
>> function readData in the LCA-file. But the example was to complex for
>> me to fully understand.
>>
>> So my question is how do I read a variable from the javascript?
>> I would appreciate if someone could post an simple example of a custom
>> widget that reads data from the qooxdoo code.
Re: Read data from custom widget. [message #122473 is a reply to message #122463] Tue, 24 February 2009 16:32 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Erik,
in your LCA#renderChanges method you can use:
JSWriter writer = JSWriter.getWriterFor( widget );
writer.call(......) or writer.callStatic(......) depend on your function.

Check the existing RAP LCAs for more details.
Best,
Ivan

Erik Haglund wrote:
> Hi thank you for the example code.
> However I have a problem related to this topic.
>
> I wan't to be able to call my qooxdoo function and read my variable at
> a given time.
> So how do I call a function in qooxdoo from the LCA?
>
> /Erik
> Ivan Furnadjiev skrev:
>> Hi Erik,
>> here is a simple code that put in the request the value of your
>> variable "this.myParam" and send the request to the server:
>> ------------
>> var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
>> var req = org.eclipse.swt.Request.getInstance();
>> var id = widgetManager.findIdByWidget( this );
>> req.addParameter( id + ".myParam", this.myParam );
>> req.send();
>> -------------
>> In your LCA#readData, you can read this parameter from the request:
>> -------------
>> String value = WidgetLCAUtil.readPropertyValue( widget, "myParam" );
>> if( value != null ) {
>> // do something if the parameter is found }
>>
>> Hope that this will help.
>> Best,
>> Ivan
>>
>> Erik Haglund wrote:
>>> Hello.
>>> I have created a custom widget which is built on qooxdoo and
>>> consists of two lists. I can populate one of the lists from the java
>>> code, but how do I read data from the list to the RAP application?
>>>
>>> I have looked at the google maps example and they are using the
>>> function readData in the LCA-file. But the example was to complex
>>> for me to fully understand.
>>>
>>> So my question is how do I read a variable from the javascript?
>>> I would appreciate if someone could post an simple example of a
>>> custom widget that reads data from the qooxdoo code.
Re: Read data from custom widget. [message #122544 is a reply to message #122473] Wed, 25 February 2009 10:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: haglund86.hotmail.com

When I use the function call:

writer.call();

from readData in the LCA-file I get an infinity loop (probably because
req.send() in the qooxdoo code triggers the readData function in the
LCA-file again and so on). This is taking alot of resources. Is it
possible to get around this problem?

Regards
Erik
Ivan Furnadjiev skrev:
> Hi Erik,
> in your LCA#renderChanges method you can use:
> JSWriter writer = JSWriter.getWriterFor( widget );
> writer.call(......) or writer.callStatic(......) depend on your function.
>
> Check the existing RAP LCAs for more details.
> Best,
> Ivan
>
> Erik Haglund wrote:
>> Hi thank you for the example code.
>> However I have a problem related to this topic.
>>
>> I wan't to be able to call my qooxdoo function and read my variable at
>> a given time.
>> So how do I call a function in qooxdoo from the LCA?
>>
>> /Erik
>> Ivan Furnadjiev skrev:
>>> Hi Erik,
>>> here is a simple code that put in the request the value of your
>>> variable "this.myParam" and send the request to the server:
>>> ------------
>>> var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
>>> var req = org.eclipse.swt.Request.getInstance();
>>> var id = widgetManager.findIdByWidget( this );
>>> req.addParameter( id + ".myParam", this.myParam );
>>> req.send();
>>> -------------
>>> In your LCA#readData, you can read this parameter from the request:
>>> -------------
>>> String value = WidgetLCAUtil.readPropertyValue( widget, "myParam" );
>>> if( value != null ) {
>>> // do something if the parameter is found }
>>>
>>> Hope that this will help.
>>> Best,
>>> Ivan
>>>
>>> Erik Haglund wrote:
>>>> Hello.
>>>> I have created a custom widget which is built on qooxdoo and
>>>> consists of two lists. I can populate one of the lists from the java
>>>> code, but how do I read data from the list to the RAP application?
>>>>
>>>> I have looked at the google maps example and they are using the
>>>> function readData in the LCA-file. But the example was to complex
>>>> for me to fully understand.
>>>>
>>>> So my question is how do I read a variable from the javascript?
>>>> I would appreciate if someone could post an simple example of a
>>>> custom widget that reads data from the qooxdoo code.
Re: Read data from custom widget. [message #122552 is a reply to message #122544] Wed, 25 February 2009 10:14 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Erik,
I do not understand why you call writer.call(); from LCA#readData? The
LCA#readData method is called to get the data from the JavaScript.
LCA#renderChanges is the place to call the JavaScript function.
Best,
Ivan

Erik Haglund wrote:
> When I use the function call:
>
> writer.call();
>
> from readData in the LCA-file I get an infinity loop (probably because
> req.send() in the qooxdoo code triggers the readData function in the
> LCA-file again and so on). This is taking alot of resources. Is it
> possible to get around this problem?
>
> Regards
> Erik
> Ivan Furnadjiev skrev:
>> Hi Erik,
>> in your LCA#renderChanges method you can use:
>> JSWriter writer = JSWriter.getWriterFor( widget );
>> writer.call(......) or writer.callStatic(......) depend on your
>> function.
>>
>> Check the existing RAP LCAs for more details.
>> Best,
>> Ivan
>>
>> Erik Haglund wrote:
>>> Hi thank you for the example code.
>>> However I have a problem related to this topic.
>>>
>>> I wan't to be able to call my qooxdoo function and read my variable
>>> at a given time.
>>> So how do I call a function in qooxdoo from the LCA?
>>>
>>> /Erik
>>> Ivan Furnadjiev skrev:
>>>> Hi Erik,
>>>> here is a simple code that put in the request the value of your
>>>> variable "this.myParam" and send the request to the server:
>>>> ------------
>>>> var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
>>>> var req = org.eclipse.swt.Request.getInstance();
>>>> var id = widgetManager.findIdByWidget( this );
>>>> req.addParameter( id + ".myParam", this.myParam );
>>>> req.send();
>>>> -------------
>>>> In your LCA#readData, you can read this parameter from the request:
>>>> -------------
>>>> String value = WidgetLCAUtil.readPropertyValue( widget, "myParam" );
>>>> if( value != null ) {
>>>> // do something if the parameter is found }
>>>>
>>>> Hope that this will help.
>>>> Best,
>>>> Ivan
>>>>
>>>> Erik Haglund wrote:
>>>>> Hello.
>>>>> I have created a custom widget which is built on qooxdoo and
>>>>> consists of two lists. I can populate one of the lists from the
>>>>> java code, but how do I read data from the list to the RAP
>>>>> application?
>>>>>
>>>>> I have looked at the google maps example and they are using the
>>>>> function readData in the LCA-file. But the example was to complex
>>>>> for me to fully understand.
>>>>>
>>>>> So my question is how do I read a variable from the javascript?
>>>>> I would appreciate if someone could post an simple example of a
>>>>> custom widget that reads data from the qooxdoo code.
Re: Read data from custom widget. [message #122563 is a reply to message #122552] Wed, 25 February 2009 11:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: haglund86.hotmail.com

Thank you for your reply.
Unfortunately this did not fix my problem with the infinity loop.

To give you a clear view of what I am doing:
LCA file:

public void renderChanges(Widget widget) throws IOException
{

JSWriter writer = JSWriter.getWriterFor(widget);
try {
writer.call("readItem", null);
} catch (IOException e) {
e.printStackTrace();
}
}
public void readData(Widget widget)
{
Dnd dnd = (Dnd) widget;
String location = WidgetLCAUtil.readPropertyValue(dnd, "listan" );
System.out.println(location);
}

javascript file:
readItem: function()
{
var test = "FREDD";
var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
var req = org.eclipse.swt.Request.getInstance();
var id = widgetManager.findIdByWidget( this );
req.addParameter( id + ".listan", test );
req.send();
},


This code will perform a infinite loop of calls to the readItem function
in the javascript file.


Ivan Furnadjiev skrev:
> Hi Erik,
> I do not understand why you call writer.call(); from LCA#readData? The
> LCA#readData method is called to get the data from the JavaScript.
> LCA#renderChanges is the place to call the JavaScript function.
> Best,
> Ivan
>
> Erik Haglund wrote:
>> When I use the function call:
>>
>> writer.call();
>>
>> from readData in the LCA-file I get an infinity loop (probably because
>> req.send() in the qooxdoo code triggers the readData function in the
>> LCA-file again and so on). This is taking alot of resources. Is it
>> possible to get around this problem?
>>
>> Regards
>> Erik
>> Ivan Furnadjiev skrev:
>>> Hi Erik,
>>> in your LCA#renderChanges method you can use:
>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>> writer.call(......) or writer.callStatic(......) depend on your
>>> function.
>>>
>>> Check the existing RAP LCAs for more details.
>>> Best,
>>> Ivan
>>>
>>> Erik Haglund wrote:
>>>> Hi thank you for the example code.
>>>> However I have a problem related to this topic.
>>>>
>>>> I wan't to be able to call my qooxdoo function and read my variable
>>>> at a given time.
>>>> So how do I call a function in qooxdoo from the LCA?
>>>>
>>>> /Erik
>>>> Ivan Furnadjiev skrev:
>>>>> Hi Erik,
>>>>> here is a simple code that put in the request the value of your
>>>>> variable "this.myParam" and send the request to the server:
>>>>> ------------
>>>>> var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
>>>>> var req = org.eclipse.swt.Request.getInstance();
>>>>> var id = widgetManager.findIdByWidget( this );
>>>>> req.addParameter( id + ".myParam", this.myParam );
>>>>> req.send();
>>>>> -------------
>>>>> In your LCA#readData, you can read this parameter from the request:
>>>>> -------------
>>>>> String value = WidgetLCAUtil.readPropertyValue( widget, "myParam" );
>>>>> if( value != null ) {
>>>>> // do something if the parameter is found }
>>>>>
>>>>> Hope that this will help.
>>>>> Best,
>>>>> Ivan
>>>>>
>>>>> Erik Haglund wrote:
>>>>>> Hello.
>>>>>> I have created a custom widget which is built on qooxdoo and
>>>>>> consists of two lists. I can populate one of the lists from the
>>>>>> java code, but how do I read data from the list to the RAP
>>>>>> application?
>>>>>>
>>>>>> I have looked at the google maps example and they are using the
>>>>>> function readData in the LCA-file. But the example was to complex
>>>>>> for me to fully understand.
>>>>>>
>>>>>> So my question is how do I read a variable from the javascript?
>>>>>> I would appreciate if someone could post an simple example of a
>>>>>> custom widget that reads data from the qooxdoo code.
Re: Read data from custom widget. [message #122606 is a reply to message #122563] Wed, 25 February 2009 13:05 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Erik,

with your code it is normal to go into infinity loop. I will suggest the
following:
1. When there is a change in the your JavaScript variable - send the new
value to the server with the code in readItem function.
2. Store the new value in your server-side Dnd widget in LCA#readData.
2. When you need to access this value just get it from your server-side
Dnd widget directly.

Best,
Ivan

Erik Haglund wrote:
> Thank you for your reply.
> Unfortunately this did not fix my problem with the infinity loop.
>
> To give you a clear view of what I am doing:
> LCA file:
>
> public void renderChanges(Widget widget) throws IOException
> {
>
> JSWriter writer = JSWriter.getWriterFor(widget);
> try {
> writer.call("readItem", null);
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> public void readData(Widget widget)
> {
> Dnd dnd = (Dnd) widget;
> String location = WidgetLCAUtil.readPropertyValue(dnd, "listan" );
> System.out.println(location);
> }
>
> javascript file:
> readItem: function()
> {
> var test = "FREDD";
> var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
> var req = org.eclipse.swt.Request.getInstance();
> var id = widgetManager.findIdByWidget( this );
> req.addParameter( id + ".listan", test );
> req.send();
> },
>
>
> This code will perform a infinite loop of calls to the readItem
> function in the javascript file.
>
>
> Ivan Furnadjiev skrev:
>> Hi Erik,
>> I do not understand why you call writer.call(); from LCA#readData?
>> The LCA#readData method is called to get the data from the
>> JavaScript. LCA#renderChanges is the place to call the JavaScript
>> function.
>> Best,
>> Ivan
>>
>> Erik Haglund wrote:
>>> When I use the function call:
>>>
>>> writer.call();
>>>
>>> from readData in the LCA-file I get an infinity loop (probably
>>> because req.send() in the qooxdoo code triggers the readData
>>> function in the LCA-file again and so on). This is taking alot of
>>> resources. Is it possible to get around this problem?
>>>
>>> Regards
>>> Erik
>>> Ivan Furnadjiev skrev:
>>>> Hi Erik,
>>>> in your LCA#renderChanges method you can use:
>>>> JSWriter writer = JSWriter.getWriterFor( widget );
>>>> writer.call(......) or writer.callStatic(......) depend on your
>>>> function.
>>>>
>>>> Check the existing RAP LCAs for more details.
>>>> Best,
>>>> Ivan
>>>>
>>>> Erik Haglund wrote:
>>>>> Hi thank you for the example code.
>>>>> However I have a problem related to this topic.
>>>>>
>>>>> I wan't to be able to call my qooxdoo function and read my
>>>>> variable at a given time.
>>>>> So how do I call a function in qooxdoo from the LCA?
>>>>>
>>>>> /Erik
>>>>> Ivan Furnadjiev skrev:
>>>>>> Hi Erik,
>>>>>> here is a simple code that put in the request the value of your
>>>>>> variable "this.myParam" and send the request to the server:
>>>>>> ------------
>>>>>> var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
>>>>>> var req = org.eclipse.swt.Request.getInstance();
>>>>>> var id = widgetManager.findIdByWidget( this );
>>>>>> req.addParameter( id + ".myParam", this.myParam );
>>>>>> req.send();
>>>>>> -------------
>>>>>> In your LCA#readData, you can read this parameter from the request:
>>>>>> -------------
>>>>>> String value = WidgetLCAUtil.readPropertyValue( widget, "myParam" );
>>>>>> if( value != null ) {
>>>>>> // do something if the parameter is found }
>>>>>>
>>>>>> Hope that this will help.
>>>>>> Best,
>>>>>> Ivan
>>>>>>
>>>>>> Erik Haglund wrote:
>>>>>>> Hello.
>>>>>>> I have created a custom widget which is built on qooxdoo and
>>>>>>> consists of two lists. I can populate one of the lists from the
>>>>>>> java code, but how do I read data from the list to the RAP
>>>>>>> application?
>>>>>>>
>>>>>>> I have looked at the google maps example and they are using the
>>>>>>> function readData in the LCA-file. But the example was to
>>>>>>> complex for me to fully understand.
>>>>>>>
>>>>>>> So my question is how do I read a variable from the javascript?
>>>>>>> I would appreciate if someone could post an simple example of a
>>>>>>> custom widget that reads data from the qooxdoo code.
Previous Topic:Again GridLayout difference with RCP (1.2 M5)
Next Topic:Multithread RAP application, ui contribution
Goto Forum:
  


Current Time: Thu Mar 28 12:34:21 GMT 2024

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

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

Back to the top