Announcement

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

    How to return a Map<String, String> from RPC DMI

    I'm currently running gwt 2.3 and smartgwtpower nightly 2.5 on rhel. I have an rpc dmi call that I want to return a map<string, string>. Is this possible? Is the best way to create a RPCResponse on the server and set an attribute with a map value and then access it from the RPCResponse on the client? I tried to cast the rawData object to a Map<string, string> but I got an error saying that it can't cast a javascriptobject to a Map.

    #2
    Yes, you can return that data - anything you return is going to be translated according to the rules listed under the server-side JSTranslater class. In this case, you can use JSOHelper.convertToMap() to get back to a Java Map.

    Comment


      #3
      Originally posted by Isomorphic
      Yes, you can return that data - anything you return is going to be translated according to the rules listed under the server-side JSTranslater class. In this case, you can use JSOHelper.convertToMap() to get back to a Java Map.
      I get an error when I try to create an RPCResponse
      Code:
      public RPCResponse foo(HttpServletRequest aRequest)
      {
      RPCResponse rpcResponse = new RPCResponse();
      rpcResponse.setAttribute("id", 
                  this.getStuff(
                        this.user.getFoo(aRequest)));
            
            return rpcResponse;
      }
      Code:
      java.lang.UnsatisfiedLinkError: com.smartgwt.client.util.JSOHelper.createObject()Lcom/google/gwt/core/client/JavaScriptObject;
      	at com.smartgwt.client.util.JSOHelper.createObject(Native Method)
      	at com.smartgwt.client.core.DataClass.<init>(DataClass.java:35)
      	at com.smartgwt.client.rpc.RPCResponse.<init>(RPCResponse.java:73)
      	at package.MyClass.foo(MyClass.java:103)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:949)
      	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:802)
      	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:305)
      	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:66)
      	at com.isomorphic.rpc.RPCRequest.execute(RPCRequest.java:229)
      	at com.isomorphic.servlet.IDACall.handleRPCRequest(IDACall.java:245)
      	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:152)
      	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
      	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
      	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
      	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
      	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.Server.handle(Server.java:324)
      	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

      Comment


        #4
        Scrambled Java imports - com.smartgwt is client-side classes, com.isomorphic is server-side classes.

        Comment

        Working...
        X