Announcement

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

    1. With Smartgwt 2.5 I do not have to built it again. As far as I understood the custom server is already implemented. Right?

    2. Can somebody supply a working solution. All uploaded files are not available anymore. Thanks!!!

    Comment


      Hi Bitblaster,

      Where can I download the source / project?

      If anyone has the source, could post a place where is avalaible?

      Thanks.

      Originally posted by bitblaster
      Hi to all, at last i managed to use filtering, sorting and pagination (lazy loading) all server-side.
      Starting from the excellent work af alius, i improved its base class GwtRpcDatasource and created a set of utility classes which help in the creation of a Rpc datasource.
      I made a simple Eclipse project showing this functionalities so that you can test it quickly and import the classes you need in your project.
      The most important innovation is the management of the advanced criterias passed from the smartgwt's FilterBuider, which are converted in a internal tree of GWTCriterions and then passed server-side where they're converted in a true-java Criterion tree, which in turn, using reflection, filters our result.

      So, briefly, in the server call you have:
      - filter criterions
      - sorting field
      - pagination start and end

      Using this information you can do your data extraction in whatever way you need and return the result to the (client) caller.
      I made a simple example with a static list of data and it works (i've not implemented the sorting, but it's trivial).

      I tried to upload here a zip (24kb) with the project, but it's not possible, so i've uploaded it to rapidshare and put here the link.

      http://rapidshare.com/files/21686999...ource.zip.html

      @Administrators: If it's in contrast with the forum rules please remove this link

      Let me know if you find bugs or a way to improve it.
      Bye
      Bit

      Comment


        Hi guys,
        This thread is very helpful and i really appreciate your work but i have a problem regarding my GwtRpcDataSource with nested data.
        I have a DS called Calendar that contains a list of CalendarDays(nested data). I want to represent all my calendars in a selectItem (which i already implemented and it works) and each time i select a calendar from the selectIteam i want to see in a listGrid the corresponding days. If you please point me to a gwt-rpc datasource example that uses nested data (within the same datasource not nested datasources) or give me a hint.

        Thank you

        Comment


          I'm using SmartGWT 2.4 and GWT 2.2 on eclipse Indigo.

          I've created a GWT project and put all of the Test code in it. On a fetch (or any service call), I get the following error:
          Code:
          14:31:45.760 [ERROR] [gwtrpc] 14:31:45.758:WARN:RPCManager:Error performing rpcRequest: error: FAILURE, response: {clientContext: Obj,
          status: -1,
          context: undef,
          startRow: 0,
          endRow: 0,
          totalRows: 0}
          
          com.smartgwt.client.core.JsObject$SGWT_WARN: 14:31:45.758:WARN:RPCManager:Error performing rpcRequest: error: FAILURE, response: {clientContext: Obj,
          status: -1,
          context: undef,
          startRow: 0,
          endRow: 0,
          totalRows: 0}
          <snip stack trace>
          Here is my EntryPoint:
          Code:
          public class YourEntryPoint implements EntryPoint {
          
          	@Override
          	public void onModuleLoad() {
          
          		Canvas canvas = new Canvas();
          		TestDataSource dataSource = new TestDataSource();
          
          		final ListGrid yourGrid = new ListGrid();
          		yourGrid.setWidth(550);
          		yourGrid.setHeight(200);
          		yourGrid.setCellHeight(22);
          		yourGrid.setDataSource(dataSource);
          
          		ListGridField nameField = new ListGridField("name", "Name");
          		ListGridField locationField = new ListGridField("date", "DATE");
          		yourGrid.setFields(nameField, locationField);
          
          		yourGrid.setAutoFetchData(true);
          //		yourGrid.setDataFetchMode(FetchMode.BASIC); 
          		yourGrid.setDataFetchMode(FetchMode.PAGED); 
          		yourGrid.setShowAllRecords(false);
          		yourGrid.setDataPageSize(20);
          		yourGrid.setCanEdit(true);
          		yourGrid.setShowFilterEditor(true);
          		yourGrid.setEditEvent(ListGridEditEvent.DOUBLECLICK);
          
                  IButton addRow = new IButton("Add new row");  
                  addRow.addClickHandler(new ClickHandler() {  
                      public void onClick(ClickEvent event) {  
                          ListGridRecord rec = new ListGridRecord();  
                          rec.setAttribute("name", "yourName");  
                          rec.setAttribute("date", new Date());                   
                          yourGrid.addData(rec);
                      }             
                  });  
                  addRow.setLeft(0);  
                  addRow.setTop(240);  
                  addRow.setWidth(140); 
                  
                  IButton removeAll = new IButton("Remove All Selected");  
                  removeAll.addClickHandler(new ClickHandler() {  
                      public void onClick(ClickEvent event) {  
                          ListGridRecord[] selectedRecords = yourGrid.getSelection();  
                          for(ListGridRecord rec: selectedRecords) {  
                              yourGrid.removeData(rec);  
                          }  
                      }             
                  });  
                  removeAll.setLeft(320);  
                  removeAll.setTop(240);  
                  removeAll.setWidth(140); 
          		
          		canvas.addChild(yourGrid);
          		canvas.addChild(addRow);
          		canvas.addChild(removeAll);
          
          		canvas.draw(); 
          		
          		// for debugging only, shows the developer console when hitting CTRL-D.
          		if (!GWT.isScript()) {
          			KeyIdentifier debugKey = new KeyIdentifier();
          			debugKey.setCtrlKey(true);
          			debugKey.setKeyName("D");
          			Page.registerKey(debugKey, new KeyCallback() {
          				public void execute(String keyName) {
          					SC.showConsole();
          				}
          			});
          		}
          	}
          
          }
          I always get this error, no matter how I use the GwtRpcDataSource. It always happens on the return from the service implementation.

          Anybody have a clue? I've also tested out the generic gwtrpcdatasource in marbot's thread and it works fine.

          Comment


            Originally posted by kimmie
            I've created a GWT project and put all of the Test code in it. On a fetch (or any service call), I get the following error:

            I always get this error, no matter how I use the GwtRpcDataSource. It always happens on the return from the service implementation.

            Anybody have a clue? I've also tested out the generic gwtrpcdatasource in marbot's thread and it works fine.
            I got it working in my project. I just had some other errors that were preventing the serialization of my object. I didn't work out exactly why the sample code wasn't working, but I don't have any more time for that.

            Comment


              SmartGWT: 2.4 (simple, I'm just a hobbist).
              Google Chrome: 17.0.963.46 (the latest version)

              I have a ListGrid with custom DataSource (based on this topic).
              On loading the page with this grid - it tries to fetch data.
              It creates service, runs executeFetch and recieves an error.

              Caught:
              Code:
              17:16:00.143 [INFO] [app] [ERROR] caught: com.google.gwt.user.client.rpc.StatusCodeException: 500 The call failed on the server; see server log for details
              Code:
              17:16:00.029 [ERROR] [app] 17:16:00.027:WARN:RPCManager:Error performing rpcRequest: error: FAILURE, response: {__gwt_ObjectId: 893, clientContext: Obj, status: -1, context: undef, startRow: 0, endRow: 0, totalRows: 0}
              com.smartgwt.client.core.JsObject$SGWT_WARN: 17:16:00.027:WARN:RPCManager:Error performing rpcRequest: error: FAILURE, response: {__gwt_ObjectId: 893, clientContext: Obj, status: -1, context: undef, startRow: 0, endRow: 0, totalRows: 0}
                  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:172)
                  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
                  at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
                  at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
                  at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
                  at com.smartgwt.client.data.DataSource.processResponse(DataSource.java)
                  at ru.app.client.ui.data.datasources.ProjectInfoDS$1.onFailure(ProjectInfoDS.java:82)
                  at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:237)
                  at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
                  at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  at java.lang.reflect.Method.invoke(Unknown Source)
                  at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                  at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                  at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
                  at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
                  at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
                  at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                  at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
                  at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
                  at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  at java.lang.reflect.Method.invoke(Unknown Source)
                  at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                  at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                  at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
                  at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
                  at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
                  at java.lang.Thread.run(Unknown Source)
              ProjectInfo - just a simple object created for DataSource tesing (only long, String, Data). Service works with DB via ProjectInfoDao with HebarnateTemplate.
              Tried to make it with gilead and without - doesn't matter.
              Simple RPC service (just recieve a String from server) works fine.
              "Extends", "implements", "web.xml", "appContext.xml" - are checked - everyting is done the same way as on simple (working) RPC service.

              I saw, that in code examples from this topic, response have the following style:
              response:
              Code:
              {clientContext: Obj, status: -1, context: undef, startRow: 0, endRow: 0, totalRows: 0}
              And I have response:
              Code:
              {[b]__gwt_ObjectId: 893[/b], clientContext: Obj, status: -1, context: undef, startRow: 0, endRow: 0, totalRows: 0}
              What is "__gwt_ObjectId: <id>"?
              Can it be a reason of my errors?
              How I can remove it from response?

              Update:
              I've tried to run dev mode on Firefox - it resolves __gwt_ObjectId problem, but the error remains the same :(:
              Code:
              22:22:47.712 [ERROR] [app] 22:22:47.707:WARN:RPCManager:Error performing rpcRequest: error: FAILURE, response: {clientContext: Obj, status: -1, context: undef, startRow: 0, endRow: 0, totalRows: 0}
              com.smartgwt.client.core.JsObject$SGWT_WARN: 22:22:47.707:WARN:RPCManager:Error performing rpcRequest: error: FAILURE, response: {clientContext: Obj, status: -1, context: undef, startRow: 0, endRow: 0, totalRows: 0}
                  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:172)
                  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
                  at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
                  at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
                  at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
                  at com.smartgwt.client.data.DataSource.processResponse(DataSource.java)
                  at ru.app.client.ui.data.datasources.ProjectInfoDS$1.onFailure(ProjectInfoDS.java:82)
                  at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:237)
                  at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
                  at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  at java.lang.reflect.Method.invoke(Unknown Source)
                  at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                  at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                  at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
                  at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
                  at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
                  at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                  at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
                  at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
                  at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  at java.lang.reflect.Method.invoke(Unknown Source)
                  at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                  at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                  at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
                  at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
                  at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
                  at java.lang.Thread.run(Unknown Source)
              Last edited by Tasmit; 11 Feb 2012, 10:27.

              Comment


                Do not use google chrome for development, use firefox. Those strange ids are coming from google chrome in dev mode. In production it will be ok.
                Br
                Marije

                Comment


                  There were serialization problems due to Date's field (though it was java.util.Date, not java.sql.Date).

                  Has anybody bitblaster's filter's example?
                  Files on rapidshare have been expired and deleted :(.
                  I need to realize server-filtering via FilterBuilder on client-side and Hibernate on server-side, but a little bit confused with sending/transforming AdvancedCriterias.

                  Comment


                    Hi guys I search a lot but can't find a understandable solution till yet.
                    Problem i have a Hierarchical object with associations.

                    Customer (firstname,lastname,age,gender ...)
                    -- Adress (street,housno,postcode,city,)(one to many )


                    I have a CustomerDataSource that fetch all the data related to customer in one request. so I get one Object CustomerData. This object holdes many objects of Class Adress inside it.

                    I donot want to use the nested Datasource for adress since i have the data.

                    How do I use this to bind it to a ListGrid and Form. so user can create a Customer with many adresses.



                    thanks in advance for a simple example.

                    Best Regards

                    Comment


                      Has any body answers for the following question from earlierpost. a sample will be nice

                      Originally posted by fbrier
                      I love the Showcase and associated sample code. It has been very helpful. But now I am trying to use gwt-rpc to retrieve hierarchical objects and store them in DynamicForm(s).

                      Looking at Alius GwtRpcDataSource code and test cases, I did not see where it was performing a fetch/add/update on hierarchical object. The example shows data being copied to and from a ListGridRecord, but not something like a Record that contains other Record(s) and/or a ListGridRecord. Or does a GwtRpcDataSource create related VirtualDataSource(s) referenced by the forms? I am very confused.

                      Plus I want to create reusable form components for objects like Addresses and possibly use them in multiple forms. It would be kind of cool if you could create a FormItem derived class that was essentially an aggregate DynamicForm. So an Address POJO would populate an AddressForm. But I did not see methods that allowed a FormItem to nest sets of focus points, just one.

                      A typical example would be a PurchaseOrder POJO that contains billTo and shipTo properties of type Address, and an array of OrderItem instances.

                      I do not want a UI that has "Bill To - Address Line 1" as the title for the first field and "Bill To - Address Line 2" as the title for the second field, etc. I would rather have "Bill To" as the title on the far left and then have a reusable AddressForm on the right with "Line 1", "Line 2", "City", "State", and "ZIP" as the title. Ideally, it would be nice if City/State/ZIP could be on the same line.

                      And if there were multiple DynamicForms spread across multiple tabs, how does the ValuesManager come into play?

                      Are there any larger application examples of SmartGWT such as PetClinic application that might demonstrate some of these techniques?

                      Thank you for any help wrapping my head around this.

                      Comment


                        This was an excellent example but I'm new to SmartGWT and am not sure how to implement a TreeGrid using your example. I would like to load on demand so when a folder is expanded I fetch the children at that time. I am able to successfully fetch the parent nodes but when I click to expand the folder I want to use a different datasource to fetch the children. I've tried looking at the information passed into the executeFetch() method to determine which parent node I"m on so I can fetch the children instead but apparently I"m not looking at the right variables. The parent nodes are "Manager" type nodes and the children nodes are "Training" nodes. So they aren't the same type of objects returned from the server.

                        I'm using SmartGWT 3.0 with FireFox 3.6.3

                        Basically what I've tried so far is as follows:
                        Code:
                        onModuleLoad() {
                        
                        DataSource dataSource = ManagerDS.getInstance();
                        TreeGrid treeGrid = new TreeGrid();
                        treeGrid.setLoadDataOnDemand(true);
                        treeGrid.setWidth(500);
                        treeGrid.setHeight(400);
                        treeGrid.setAutoFetchData(true);
                        treeGrid.setDataSource(datasource);
                        
                        TreeGridField field = new TreeGridField("manager", "Managers");
                        treeGrid.setFields(field);
                        treeGrid.fetchData();
                        treeGrid.draw();
                        
                        }
                        
                        public class ManagerDS extends GwtRPTDataSource {
                        
                        private static ManagerDS instance = null;
                        
                        public static ManagerDS getInstance() {
                          if (instance == null) {
                             instance = new ManagerDS();
                          }
                          return instance;
                        }
                        
                        
                        public ManagerDS() {
                        
                          DataSourceTextField username = new DataSourceTextField("username", "Username");
                          username.setPrimaryKey(true);
                        
                         setFields(username);
                        
                        }
                        
                        @Override
                        protected void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
                         
                        /// in this method I would like to determine which ManagerNode is selected 
                        // or is the first time called and we are getting all managers. If a  
                        // managerNode is selected and the tree is to be expanded I will call the 
                        // TrainingService.class instead of the ManagerService.class so I can fetch //all the training classes this manager has taken
                         
                        
                           ManagerServiceAsync mgrService = GWT.create(ManagerService.class);
                           mgrService.fetch(new AsyncCallback<List<ManagerRecord>> () {
                        
                                  @Override
                                  public void onSuccess(List<ManagerRecord> result) {
                                                     ListGridRecord[] list = new ListGridRecord[result.size()];
                                                     for (int i=0; i<list.length; i++) {
                                                               ListGridRecord record = new ListGridRecord();
                                                               copyValues(result.get(i), record);
                                                               list[i] = record;
                                                     }
                                                     response.setData(list);
                                                     processResponse(requestId, response);
                                    }
                        
                                   @Override
                                   public void onFailure(Throwable caught) {
                                  }
                        
                           }
                        
                           private static Boolean copyValues(ListGridRecord from, ManagerRecord to) {
                                     to.setUsername(from.getAttributeAsString("username");
                        }
                        
                           private static Boolean copyValues(ManagerRecord from, ListGridRecord to) {
                                    to.setAttribute("username", from.getUsername());
                        }
                        }
                        
                        
                        
                        public class ManagerRecord {
                        
                         private String username;
                        
                         public String getUsername() {
                        return username;
                        }
                         public void setUsername(String username) {
                            this.username = username;
                        }
                        }
                        
                        public class TrainingRecord {
                          private String trainingName;
                        
                          public String getTrainingName() {
                               return trainingName;
                           }
                           public void setTrainingName(String trainingName) {
                                this.trainingName = trainingName;
                           }
                        }

                        Comment


                          Since you're new, please note that we now strongly recommend against using GWT-RPC, for reasons listed in the FAQ.

                          Comment


                            Originally posted by Isomorphic
                            Since you're new, please note that we now strongly recommend against using GWT-RPC, for reasons listed in the FAQ.
                            Thank you for your response. I'm new to smartgwt but the project I work on is already established and so I'm trying to add on to what is there. I have it mostly working except that I can't figure out how to get the parentId from DSRequest.

                            In my previous code example I modified the DataSource to add the parentId field. Yet when I try to get the attribute using the following code example nothing is returned for 'parentId'. On loadDataOnDemand how do I get the selected parent node's parentId passed into the executeFetch?

                            Code:
                             the executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
                            
                                String parentId = request.getCriteria().getAttribute("parentId");
                            }
                            Code:
                            onModuleLoad() {
                            
                            DataSource dataSource = ManagerDS.getInstance();
                            TreeGrid treeGrid = new TreeGrid();
                            treeGrid.setLoadDataOnDemand(true);
                            treeGrid.setWidth(500);
                            treeGrid.setHeight(400);
                            treeGrid.setAutoFetchData(true);
                            treeGrid.setDataSource(datasource);
                            
                            TreeGridField field = new TreeGridField("manager", "Managers");
                            treeGrid.setFields(field);
                            treeGrid.fetchData();
                            treeGrid.draw();
                            
                            }
                            
                            public class ManagerDS extends GwtRPTDataSource {
                            
                            private static ManagerDS instance = null;
                            
                            public static ManagerDS getInstance() {
                              if (instance == null) {
                                 instance = new ManagerDS();
                              }
                              return instance;
                            }
                            
                            
                            public ManagerDS() {
                            
                            
                              DataSourceTextField username = new DataSourceTextField("username", "Username");
                              username.setPrimaryKey(true);
                            addField(username);
                            
                              DataSourceIntegerField id = new DataSourceIntegerField("parentId", "parentId");
                             parentIdField.setRequired(true);
                             parentIdField.setHidden(true);
                              addField(parentIdField);
                            
                            }
                            
                            @Override
                            protected void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
                             
                            /// in this method I would like to determine which ManagerNode is selected 
                            // or is the first time called and we are getting all managers. If a  
                            // managerNode is selected and the tree is to be expanded I will call the 
                            // TrainingService.class instead of the ManagerService.class so I can fetch //all the training classes this manager has taken
                             
                            // I get null for parentId below
                                String parentId = request.getCriteria().getAttribute("parentId");
                            
                               ManagerServiceAsync mgrService = GWT.create(ManagerService.class);
                               mgrService.fetch(new AsyncCallback<List<ManagerRecord>> () {
                            
                                      @Override
                                      public void onSuccess(List<ManagerRecord> result) {
                                                         ListGridRecord[] list = new ListGridRecord[result.size()];
                                                         for (int i=0; i<list.length; i++) {
                                                                   ListGridRecord record = new ListGridRecord();
                                                                   copyValues(result.get(i), record);
                                                                   list[i] = record;
                                                         }
                                                         response.setData(list);
                                                         processResponse(requestId, response);
                                        }
                            
                                       @Override
                                       public void onFailure(Throwable caught) {
                                      }
                            
                               }
                            
                            
                               private static Boolean copyValues(ListGridRecord from, ManagerRecord to) {
                                         to.setUsername(from.getAttributeAsString("username");
                                         to.setId(from.getAttributeAsInt("parentId");
                            }
                            
                               private static Boolean copyValues(ManagerRecord from, ListGridRecord to) {
                                        to.setAttribute("username", from.getUsername());
                                        to.setAttribute("parentId", from.getId());
                            }
                            }

                            Comment


                              Originally posted by Isomorphic
                              Since you're new, please note that we now strongly recommend against using GWT-RPC, for reasons listed in the FAQ.
                              I retried using the following code. Whenever I expand a folder I would like the folder information so I can fetch the children correctly.

                              [Code]

                              onModuleLoad() {

                              DataSource dataSource = new DataSource() {
                              @Override
                              protected Object transformRequest(DSRequest dsRequest) {
                              Criteria criteria = dsRequest.getCriteria();
                              String parentId = criteria.getAttribute("parentId");
                              Window.alert("parentId="+parentId);
                              }

                              }

                              DataSourceTextField username = new DataSourceTextField("username", "Username");
                              username.setPrimaryKey(true);


                              DataSourceIntegerField id = new DataSourceIntegerField("parentId", "parentId");
                              parentIdField.setRequired(true);
                              parentIdField.setHidden(true);

                              dataSource.setFields(username, id);
                              dataSource.setDataURL("/context/my.jsp");
                              dataSource.setDataFormat(DSDataFormat.JSON);

                              TreeGrid treeGrid = new TreeGrid();
                              treeGrid.setLoadDataOnDemand(true);
                              treeGrid.setWidth(500);
                              treeGrid.setHeight(400);
                              treeGrid.setAutoFetchData(true);
                              treeGrid.setDataSource(datasource);

                              TreeGridField field = new TreeGridField("manager", "Managers");
                              treeGrid.setFields(field);
                              treeGrid.fetchData();
                              treeGrid.draw();

                              }

                              Comment


                                Read the Tree Databinding overview - one obvious problem is that you have no foreignKey declaration at all.

                                Comment

                                Working...
                                X