Announcement

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

    DataSource + RPC

    Hello
    I'm writting simple app in which my datasource comunicates with rpc service. For example my rpc send JSON object to datasource. I have problem with adding this object to my ListGrid. Below is code.
    I would by grateful if you help me.
    Thanks

    Code:
    public class JSONServiceImpl extends RemoteServiceServlet implements JSONService {
    
        public String myMethod() {
          return "{"
                  + "id:1,"
                  + "name:\"Name\""
                  + "}";
        }
    }
    Code:
       @Override
        protected Object transformRequest(DSRequest dsRequest) {
           final String requestId = dsRequest.getRequestId ();
            final DSResponse response = new DSResponse ();
            
            response.setAttribute ("clientContext", dsRequest.getAttributeAsObject ("clientContext"));
            response.setStatus (0);
            JSONServiceAsync service = GWT.create (JSONService.class);
            service.myMethod(new AsyncCallback<String> () {
                public void onFailure (Throwable caught) {
                    response.setStatus (RPCResponse.STATUS_FAILURE);
                    SC.say("Failure");
                    processResponse (requestId, response);
                }
    
                public void onSuccess (String result) {
    
                    ListGridRecord r = new ListGridRecord( JSONEncoder.decode(result));
    
                    response.setData(r);
                    processResponse (requestId, response);
                }
        });
            return dsRequest.getData();
        }

    #2
    Don't use a DataSource with a RPC.

    http://forums.smartclient.com/showth...t=8159#aGWTRPC

    Comment

    Working...
    X