Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to call the methods of client remoteobject from server side
How to call the methods of client remoteobject from server side [message #1386292] Mon, 16 June 2014 11:59 Go to next message
osfreeman zhang is currently offline osfreeman zhangFriend
Messages: 13
Registered: May 2014
Junior Member
Hi:
I am writing rap program with remoteobject. inthe server side remoteobject I want to call a method defined in the client remoteobject. I tried to use call(method,properties), but nothing happened. I really need the immediate results in the server side remoteobject. so I do not want to implement it by notification.
could anyone help me?
regards!
Re: How to call the methods of client remoteobject from server side [message #1386297 is a reply to message #1386292] Mon, 16 June 2014 12:09 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 1921
Registered: July 2009
Senior Member
Hi,
in your client typeHandler you have to define all available methods that
will be called by the server:
------
rap.registerTypeHandler( "my.customWidgetType", {
....
methods : [ "callMe" ]
} );
------
See also RAP custom widgets FAQ:
https://wiki.eclipse.org/RAP/Custom_Widgets_FAQ

HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to call the methods of client remoteobject from server side [message #1386298 is a reply to message #1386297] Mon, 16 June 2014 12:13 Go to previous messageGo to next message
osfreeman zhang is currently offline osfreeman zhangFriend
Messages: 13
Registered: May 2014
Junior Member
thanks Ivan for your reply. I defined the methods in my client handler. but when in called in the server side,nothing happened. could you show me how to call in the server side remoteobject with an example? thanks very much.
Re: How to call the methods of client remoteobject from server side [message #1386301 is a reply to message #1386298] Mon, 16 June 2014 12:26 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 1921
Registered: July 2009
Senior Member
Hi,
it's like in your example:
remoteObject.call( "methodName", properties );
..... and in your typeHandler you have:
"methods" : [ "methodName" ]
The function "methodName" is actually implemented in your JavaScript
custom widget object.
Do you see your method called in the protocol JSON message?
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to call the methods of client remoteobject from server side [message #1386302 is a reply to message #1386301] Mon, 16 June 2014 12:38 Go to previous messageGo to next message
osfreeman zhang is currently offline osfreeman zhangFriend
Messages: 13
Registered: May 2014
Junior Member
no,I can get nothing at all. I defined a method as:
methodname: function(){
//do something
}
is that right? or how should I define the methods in the Javascript?
Re: How to call the methods of client remoteobject from server side [message #1386307 is a reply to message #1386302] Mon, 16 June 2014 12:50 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 1921
Registered: July 2009
Senior Member
Yes... that's correct.
Could you attach your custom widget source code... or part of it
responsible for method call? Please look at HTTP response when you call
the method from the server-side. Do you see a JSON call operation in the
protocol message? A fragment like:

|["call","w13","myMethod",{}]|

Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to call the methods of client remoteobject from server side [message #1386317 is a reply to message #1386307] Mon, 16 June 2014 13:37 Go to previous messageGo to next message
osfreeman zhang is currently offline osfreeman zhangFriend
Messages: 13
Registered: May 2014
Junior Member
okay.
in the client side:
rap.registerTypehandler("demo.customwidget",{
......
methods: ["testcall"]

......
});

demo.customwidget.prototype={
testcall : function(){
//do something
}
......
in the server side:

remoteobject.call("testcall",null);



at the same time, I want to get a string alike result from the call. could the remoteobject call make it?
Re: How to call the methods of client remoteobject from server side [message #1386319 is a reply to message #1386317] Mon, 16 June 2014 13:54 Go to previous messageGo to next message
osfreeman zhang is currently offline osfreeman zhangFriend
Messages: 13
Registered: May 2014
Junior Member
and I use livehttpheaders in firefox catch the http response. but I can not see anything about method call.
Re: How to call the methods of client remoteobject from server side [message #1386323 is a reply to message #1386319] Mon, 16 June 2014 14:12 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 1921
Registered: July 2009
Senior Member
Hi,
your code looks good. If there is no call operation in response JSON
message your remoteObject.call is not invoked. Without a complete widget
code I can't help you much.
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to call the methods of client remoteobject from server side [message #1386828 is a reply to message #1386323] Fri, 20 June 2014 23:16 Go to previous messageGo to next message
osfreeman zhang is currently offline osfreeman zhangFriend
Messages: 13
Registered: May 2014
Junior Member
thanks very much. I fixed it.
Re: How to call the methods of client remoteobject from server side [message #1387595 is a reply to message #1386828] Wed, 25 June 2014 09:52 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 1921
Registered: July 2009
Senior Member
Hi,
please share with the community what was the problem.
Thanks,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Workbench and Sessions
Next Topic:[ANN] RAP 2.3 released
Goto Forum:
  


Current Time: Mon Mar 02 19:09:53 GMT 2015

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

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