Permalink
Browse files

rpc stuff

  • Loading branch information...
1 parent ddd6c97 commit e533d6fa0916898186115be48be2fd00ab6f98b3 @sbryzak committed Jan 25, 2012
Showing with 68 additions and 0 deletions.
  1. +8 −0 war/hello.xw
  2. +60 −0 war/script/xw/org/xwidgets/errai/rpc.js
View
@@ -3,6 +3,8 @@
<errai:messageBus id="bus" service="HelloWorldService"/>
+ <errai:rpc id="rpc" service="org.js.test.server.HelloService:RPC"/>
+
<errai:subscriber topic="WindowAlertTopic">
<xw:event type="onmessage">
<xw:action type="script">window.alert(msg.Value + " @ server time " + msg.systemTime);</xw:action>
@@ -15,4 +17,10 @@
</xw:event>
</xw:button>
+ <xw:button label="Invoke RPC">
+ <xw:event type="onclick">
+ <xw:action type="script">rpc.invoke("foo");</xw:action>
+ </xw:event>
+ </xw:button>
+
</xw:view>
@@ -0,0 +1,60 @@
+package("org.xwidgets.errai");
+
+org.xwidgets.errai.Rpc = function() {
+ xw.NonVisual.call(this);
+ this._className = "org.xwidgets.errai.Rpc";
+ this.registerProperty("service");
+};
+
+org.xwidgets.errai.Rpc.prototype = new xw.NonVisual();
+
+org.xwidgets.errai.Rpc.prototype.open = function() {
+ if (!xw.Sys.isDefined(errai)) {
+ var that = this;
+ var o = {fire: function() { that.init(); }};
+ xw.Event.registerObserver("erraiOnLoad", o);
+ } else {
+ this.init();
+ }
+};
+
+org.xwidgets.errai.Rpc.prototype.init = function() {
+ this.bus = new errai.MsgBus();
+};
+
+org.xwidgets.errai.Rpc.prototype.invoke = function(value) {
+{
+ var parms = {};
+ parms["^EncodedType"] = "[Ljava.lang.Object;";
+ parms["^ObjectID"] = "1";
+ parms["^Value"] = [ value ];
+
+ var payload = {CommandType : "sayHello:java.lang.String:",
+ MethodParms: parms
+// ReplyTo:
+// ErrorTo:
+ }};
+
+ this.bus.send(this.service, payload);
+
+ /*
+ "org.jboss.xwidgetserrai.client.shared.HelloService:RPC", {});
+ "ToSubject": ,
+ "CommandType": "sayHello:java.lang.String:",
+ "MethodParms": {
+ "^EncodedType": "[Ljava.lang.Object;",
+ "^ObjectID": "1",
+ "^Value": [
+ "foo"
+ ]
+ },
+ "ReplyTo": "org.jboss.xwidgetserrai.client.shared.HelloService:RPC.sayHello:java.lang.String::RespondTo:2",
+ "ErrorTo": "org.jboss.xwidgetserrai.client.shared.HelloService:RPC.sayHello:java.lang.String::Errors:2"
+ }*/
+};
+
+org.xwidgets.errai.Rpc.prototype.toString = function() {
+ return "org.xwidgets.errai.Rpc[" + this.service + "]";
+};
+
+

0 comments on commit e533d6f

Please sign in to comment.