Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Is it possible to attach listeners to client objects?(RAP remote objects)
Is it possible to attach listeners to client objects? [message #1818744] Thu, 26 December 2019 16:58 Go to next message
Xi Jin is currently offline Xi JinFriend
Messages: 5
Registered: May 2018
Junior Member
Hello,

I was wondering if it is possible to attach listeners to the client objects? If I have the following code snippet at the server side:

 Text text = new Text(parentComposite, style);
 Connection connection = RWT.getUISession().getConnection();
 RemoteObject remoteObject = connection.createRemoteObject("handleText");
 JsonObject jsonObject = new JsonObject();
 jsonObject.add("textId", WidgetUtil.getId(text)); 
 remoteObject.call("setHandleText", jsonObject);

 remoteObject.setHandler(new AbstractOperationHandler()
        {
            private static final long serialVersionUID = -5974109377349489064L;

            @Override
            public void handleNotify(String event, JsonObject properties)
            {
                System.out.println("The event raised is: " + event); 
            }
        });



And on the client side I have:
rap.registerTypeHandler("handleText", {
	  factory: function(properties)
	  {
	  	 return new HandleTextObject(properties);  	
	  },
	  
	  methods : ["setHandleText"],
	  events: [ "Verify"]
	});
	
	HandleTextObject = function(properties)
	{
	}
	
	HandleTextObject.prototype = {
		handleVerifyEvent:function(event) {
                event.doit = false;
	        var widget = event.widget;
	       widget.setText("Goodbye");
	},
	
		setHandleText:function(json)
		{
		   var text = rap.getObject(json["textId"]);
		   text.addListener(SWT.Verify,this.handleVerifyEvent);
		   text.setText("Hello World");
		   console.log("Text set");
		}
	}


The setText() in setHandleText on the client side doesn't seem to be triggering the handleVerifyEvent or the handleNotify() on the server side. Do I need to use rap.on(event type, listener) to register the handleVerifyEvent as a listener, if that is the case then what event types are supported? Also, it doesn't explain why handleNotify() won't get triggered? What am I missing? Any advice would be appreciated.

[Updated on: Fri, 27 December 2019 22:14]

Report message to a moderator

Re: Is it possible to attach listeners to client objects? [message #1819432 is a reply to message #1818744] Wed, 15 January 2020 10:56 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2429
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,

yes.. it's possible. See Scripting section in RAP Developers Guide [1].

[1] https://www.eclipse.org/rap/developers-guide/devguide.php?topic=scripting.html&version=3.11

Regards,
Ivan
Previous Topic:CTabFolder/CTabItem: Wrong font on CSS theme switch
Next Topic:How to i turn off form autocompletion in RAP?
Goto Forum:
  


Current Time: Thu Dec 12 18:08:12 GMT 2024

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

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

Back to the top