Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to initiate RPCDMI from client

    Hi,

    I have a question...

    I don't seem able to figure out how to call a servermethod via RPC DMI from the client?
    I have used the getTimeStampDMI as an example and I have setup the app.xml and binding stuff, no problem.

    In the documentation I can see the DMI.call(...) and see how it works.

    However, from the client this "DMI.call" isn't possible. I'm trying to call this from behind a button like so:

    Code:
    		RootPanel.get().add(new Button("Get TimeStamp via RPC DMI", new ClickHandler() {
    			
    			public void onClick(ClickEvent event) {
    				//issue an RPCDMI call here
    			}
    		}));
    How do I issue the RPC DMI call here? Via a RPCManager.send?
    If so, how is the binding done... in other words what required parameters do I need to provide in the request (serverMethod, arguments, etc.) so that the underlying RPCManager knows this is a RPC DMI call?

    Thanx a lot for helping me out!

    #2
    This isn't available in SGWT except via JSNI at the moment. Consider instead DataSource.performCustomOperation(), which is usually more convenient anyway.

    Comment


      #3
      SmartGWTEE, latest nighlty build and using IE.

      Ok, following your suggestion (thanks for the answer) I implemented the following. Which seems to work... until the result from my custom operation is returned.

      The callback fails for some reason...

      Code:
      <DataSource ID="238">
      <fields>
      ...
      </fields>
      <serverObject ID="238" lookupStyle="new" className="server.stores.billingitem.BillingItemStore"/>
      <operationBindings>
      <binding operationId="getTimeStamp" operationType="custom" serverMethod="getTimeStamp">
      <serverObject lookupStyle="new" className="server.stores.billingitem.BillingItemStore"/>
      </binding>
      </operationBindings>
      </DataSource>
      Added this code to my serverobject declared above
      Code:
      public String getTimeStamp(){
        return DateUtil.getCurrentTimeStamp();
      }
      Added this code to call the custom operation
      Code:
      RootPanel.get().add(new Button("perform custom call", new ClickHandler() {
      
      	public void onClick(ClickEvent event) {
      		com.smartgwt.client.data.DataSource ds = com.smartgwt.client.data.DataSource.get("238");
      		
      		ds.performCustomOperation("getTimeStamp", new Record(), new DSCallback() {
      			
      			public void execute(DSResponse response, Object rawData, DSRequest request) {
      				RootPanel.get().add(new Label("Response = " + (String) rawData));
      			}
      		}, new DSRequest());
      
      	}
      
      }));
      Got this warning... can't figure out why my DSCallback isn't called?

      Code:
      === 2010-07-07 13:49:03,413 [l0-5] DEBUG BasicDataSource - Done validating a 'ServerObject' at path '/DataSource[@ID=238]/operationBindings/binding/serverObject': 3ms
      === 2010-07-07 13:49:03,413 [l0-5] DEBUG BasicDataSource - Done validating 1 'OperationBinding's at path '/DataSource[@ID=238]/operationBindings': 3ms (avg 3)
      === 2010-07-07 13:49:03,413 [l0-5] DEBUG BasicDataSource - Done validating a 'DataSource' at path '': 38ms
      === 2010-07-07 13:49:03,413 [l0-5] DEBUG DataSource - Creating instance of DataSource '238'
      === 2010-07-07 13:49:03,415 [l0-5] DEBUG Reflection - adaptArgsAndInvoke:
      
       public java.lang.String server.stores.billingitem.BillingItemStore.getTimeStamp()
      
      requiredArgs: [] optionalArgs: [com.isomorphic.servlet.RequestContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletContext, javax.servlet.http.HttpSession, com.isomorphic.rpc.RPCManager, com.isomorphic.datasource.DSRequest, com.isomorphic.datasource.DataSource, java.sql.Connection, com.isomorphic.log.Logger, java.util.Map]
      === 2010-07-07 13:49:03,415 [l0-5] DEBUG Reflection - method takes: 0 args.  I've assembled: 0 args
      === 2010-07-07 13:49:03,415 [l0-5] DEBUG Reflection - invoking method:
      java.lang.String server.stores.billingitem.BillingItemStore.getTimeStamp()
      
      with arg types: (empty parameter list)
      === 2010-07-07 13:49:05,349 [l0-5] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2010-07-07 13:49:05,349 [l0-5] DEBUG ProxyHttpServletResponse - Using charset: UTF-8 (CompressionFilter)
      === 2010-07-07 13:49:05,352 [l0-5] INFO  Compression - /silkroad/sc/IDACall: 128 -> 125 bytes
      [20100707 13:49:05] 13:49:05.375:XRP6:WARN:DataSource:fireCallback() unable to convert callback: client.SilkRoadMasterPanel$8$1@c9905e to a function.  target: [DataSource ID:238], argNames: dsResponse,data,dsRequest, args: [object Object],2010-07-07 13:49:05.348,[object Object]
      com.smartgwt.client.core.JsObject$SGWT_WARN: 13:49:05.375:XRP6:WARN:DataSource:fireCallback() unable to convert callback: client.SilkRoadMasterPanel$8$1@c9905e to a function.  target: [DataSource ID:238], argNames: dsResponse,data,dsRequest, args: [object Object],2010-07-07 13:49:05.348,[object Object]
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      	at java.lang.reflect.Constructor.newInstance(Unknown Source)
      	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
      	at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
      	at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
      	at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
      	at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
      	at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
      	at java.lang.Thread.run(Unknown Source)
      Last edited by bade; 7 Jul 2010, 03:47.

      Comment


        #4
        There was a bug here, it's fixed in the next nightly.

        Comment


          #5
          Verified! Thanx a million...

          Comment


            #6
            I do exactly the same as the original poster but get the following error:

            "Operation type 'custom' not supported by this DataSource "

            even though the binding tag in the datasource is as follows:

            Code:
            <binding operationId="getTimeStamp" operationType="custom"
            serverMethod="getTimeStamp"> 
            <serverObject lookupStyle="new"
            className="rappsilber.web.ui.server.opbindings.SpecViewer"/>
            </binding>

            I use the latest nightly i.e. smartgwtee-2.3.zip 23-Jul-2010 04:09

            Comment


              #7
              Any ideas? Isomorphic?

              Comment


                #8
                Show the complete DataSource definition.

                Comment


                  #9
                  Attached

                  Code:
                  <DataSource ID="spec_viewer" serverType="generic">
                  	<fields>
                  		<field type="text" length="10000" name="viewer_script"></field>
                  	</fields>
                  	
                  	<serverObject ID="spec_viewer" lookupStyle="new" className="rappsilber.web.ui.server.opbindings.SpecViewer"/>
                  	
                  	<operationBindings>
                  		<operationBinding operationId="getTimeStamp" operationType="custom" serverMethod="getTimeStamp" customValueFields="spec_viewer">
                  			<serverObject lookupStyle="new" className="rappsilber.web.ui.server.opbindings.SpecViewer"/>
                  		</operationBinding>
                  		
                  	
                  		
                  	</operationBindings>
                  </DataSource>

                  code called in the client:

                  Code:
                                  IButton test = new IButton("test");
                  
                  		test.addClickHandler(new ClickHandler() {
                  			
                  			public void onClick(ClickEvent event) {
                  				com.smartgwt.client.data.DataSource ds2 = com.smartgwt.client.data.DataSource.get("spec_viewer");
                  				
                  				ds2.performCustomOperation("getTimeStamp", new Record(), new DSCallback() {
                  					
                  					public void execute(DSResponse response, Object rawData, DSRequest request) {
                  						 SC.say("Aye");
                  						//SC.say("Response = " + (String) rawData );
                  					}
                  				}, new DSRequest());
                  				
                  
                  
                  			}
                  
                  		});
                  Attached Files
                  Last edited by salman; 26 Jul 2010, 10:55.

                  Comment


                    #10
                    You've set a serverObject outside of operationBindings, which means that object will be used for all operationTypes, with the serverMethod defaulted to the operationType ('fetch', 'update', etc). Since that object has no method "custom", there's no implementation available.

                    You can either implement a method "custom" on the serverObject used for all operations, or define an operationBinding for all operationTypes in use, or switch to using DataSource.serverConstructor and creating a subclass of BasicDataSource where you override execute() to add custom logic - just a matter of which produces the least code for you.

                    Comment

                    Working...
                    X