Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » a custom widget that make ajax call to communicate with the rap server
icon4.gif  a custom widget that make ajax call to communicate with the rap server [message #536828] Mon, 31 May 2010 08:01 Go to next message
Owen  is currently offline Owen Friend
Messages: 17
Registered: May 2010
Junior Member
Hi,

RIght now I am making a widget that is able to make ajax calls to Github API (http://develop.github.com/) getting the content, and then send the content back to the rap server. The followings are the steps that I wanna achieve:

1. rap server asks the rap client to make an ajax call to GitHub
2. rap client makes an ajax call to GitHub and gets the content
3. rap client sends this content back to the rap server for further processing
4. rap server update the rap client

Here is the flow:

rap server (1)-> rap client (2)-> GitHub server (2)-> rap client (3)-> rap server (4)-> rap client

Step 1 and 2 are easy to achieved with a QooXDoo plugin and there are examples for that already, e.g., http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. rap.help/help/html/advanced/custom-widget.html. But I am having trouble building the custom event mechanism the makes ajax calls back between the rap client and the rap server (3 in this example). Is there any API I can use? Or is there an example I can take a look at?

Many thanks,
Owen
Re: a custom widget that make ajax call to communicate with the rap server [message #537133 is a reply to message #536828] Tue, 01 June 2010 12:37 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Owen,

first of all, wouldn't it be better to let the server do the github
fetch? I guess this would fit better with RAP's server-side application
paradigm. The client should only render the user interface.

We plan to provide a new API on the client with the introduction of a
protocol between client and server (bug 311355). Until then you can use
code like the following to add a request parameter to an Ajax call:

var req = org.eclipse.swt.Request.getInstance();
req.addParameter( "your.parameter", value );
req.send();

If a custom widget triggers this call, the parameter should be prefixed
with it's widget id.

Does this answer your question?

Regards, Ralf

Owen wrote:
> Hi,
>
> RIght now I am making a widget that is able to make ajax calls to Github
> API (http://develop.github.com/) getting the content, and then send the
> content back to the rap server. The followings are the steps that I
> wanna achieve:
>
> 1. rap server asks the rap client to make an ajax call to GitHub
> 2. rap client makes an ajax call to GitHub and gets the content
> 3. rap client sends this content back to the rap server for further
> processing
> 4. rap server update the rap client
>
> Here is the flow:
>
> rap server (1)-> rap client (2)-> GitHub server (2)-> rap client (3)->
> rap server (4)-> rap client
>
> Step 1 and 2 are easy to achieved with a QooXDoo plugin and there are
> examples for that already, e.g.,
> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. rap.help/help/html/advanced/custom-widget.html
> But I am having trouble building the custom event mechanism the makes
> ajax calls back between the rap client and the rap server (3 in this
> example). Is there any API I can use? Or is there an example I can take
> a look at?
>
> Many thanks,
> Owen
Re: a custom widget that make ajax call to communicate with the rap server [message #537209 is a reply to message #537133] Tue, 01 June 2010 15:24 Go to previous message
Owen  is currently offline Owen Friend
Messages: 17
Registered: May 2010
Junior Member
Hi Ralf,

Thanks for the reply.

Yup, we did consider using server to fetch the content, but somehow there are API call limits in github, that's why we wanna put this on the client.

Another thing is I am not sure if it's possible to make a headless widget in this respect : making ajax calls to other server and then transfer the content back to the rap server. Could u give me some pointers on this?

Many thanks,
Owen


Ralf Sternberg wrote on Tue, 01 June 2010 08:37
Hi Owen,

first of all, wouldn't it be better to let the server do the github
fetch? I guess this would fit better with RAP's server-side application
paradigm. The client should only render the user interface.

We plan to provide a new API on the client with the introduction of a
protocol between client and server (bug 311355). Until then you can use
code like the following to add a request parameter to an Ajax call:

var req = org.eclipse.swt.Request.getInstance();
req.addParameter( "your.parameter", value );
req.send();

If a custom widget triggers this call, the parameter should be prefixed
with it's widget id.

Does this answer your question?

Regards, Ralf

Owen wrote:
> Hi,
>
> RIght now I am making a widget that is able to make ajax calls to Github
> API (http://develop.github.com/) getting the content, and then send the
> content back to the rap server. The followings are the steps that I
> wanna achieve:
>
> 1. rap server asks the rap client to make an ajax call to GitHub
> 2. rap client makes an ajax call to GitHub and gets the content
> 3. rap client sends this content back to the rap server for further
> processing
> 4. rap server update the rap client
>
> Here is the flow:
>
> rap server (1)-> rap client (2)-> GitHub server (2)-> rap client (3)->
> rap server (4)-> rap client
>
> Step 1 and 2 are easy to achieved with a QooXDoo plugin and there are
> examples for that already, e.g.,
> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. rap.help/help/html/advanced/custom-widget.html
> But I am having trouble building the custom event mechanism the makes
> ajax calls back between the rap client and the rap server (3 in this
> example). Is there any API I can use? Or is there an example I can take
> a look at?
>
> Many thanks,
> Owen

Previous Topic:Use of IObjectActionDelegate not Synchronized
Next Topic:DateTime-Widget not reliable
Goto Forum:
  


Current Time: Fri Apr 26 15:55:11 GMT 2024

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

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

Back to the top