Is it possible to attach listeners to client objects? [message #1818744] |
Thu, 26 December 2019 16:58 |
Xi Jin 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02800 seconds