Announcement

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

    #91
    Originally posted by jsantaelena
    Dmitriy,

    Here is my project that I'm using as a proof of concept. It's using my own customization of GWT RPC DS to work with Calendar, but it contains what you are looking for.

    http://www.4shared.com/file/108426527/9ed28154/calendar2.html

    Att,

    Att,

    I was able to run your code to see the datasource in action.

    Thank you very much,
    Dmitriy

    Comment


      #92
      Load on demand TreeGrid

      I've continued my quest to use a GWT-RPC data source to drive a load on demand TreeGrid. I believe I've isolated my problem to somehow being unable to capture the request data from the ResultTree.

      My understanding of the process is as follows:

      1) User selects a node in the TreeGrid
      2) TreeGrid issues a fetchData() to retrieve children
      3) fetchData() creates a ResultTree that includes the children request as a criteria in dsRequest.data
      4) DataSource gets the dsRequest
      5) Since DataSource dataProtocol is set to CLIENTCUSTOM for GWT-RPC, the criteria remains as dsRequest.data, available for processing in transformRequest

      Everything seems to proceed as expected except that the data field is always null coming from a TreeGrid fetchData() when I try to process it in transformRequest.

      Any hints on what I'm doing wrong?

      Thanks!

      Joe

      Comment


        #93
        @jandrulis Try posting the code for your attempts. No one can tell what you might be doing wrong without seeing the code.

        Comment


          #94
          Load on demand TreeGrid

          Thanks for responding, Isomorphic. I really love what I've seen of your library. I'm sure once I get past my start up confusion, it will save me tremendous time and effort.

          I've been using the example code provided in the TestAdvDataSource project provided in this thread to extract the filter criterion from the request object which is why I didn't embed it again here. I should have be clearer about that.

          After some additional investigation, it turns out that what I interpreted as an uninitialized DSRequest object was really due to this example having been created to handle the criteria format coming from the advanced filter builder but not the simpler criteria format coming from a tree grid and returning 'null' as a result. After examining the raw data field I could see the differences and believe I now understand what I need to do to handle the tree grid to support load on demand.

          Joe

          Comment


            #95
            fetching TreeGrid

            Helo everyone, I'm trying fetching treegrid on demand but i couldn't.

            How can i distinguish first load of treegrid from other one when user click "plus" to see it childnodes? I've tried printing various getters of request and response... on override method "executeFetch" to see if i can get the diference without success.

            thanks for advance for your help!

            Comment


              #96
              For the initial fetch, the criteria in dsRequest.data will contain the parentIdField with the rootValue specified on the parentIdField. For subsequent requests, the criteria will be the parentIdField with the ID of whatever node is being opened. See the Tree DataBinding overview.

              Comment


                #97
                Originally posted by felixx
                Hi,
                Has anyone tried to use the GwtRpcDatSource with a TileGrid?
                I just can't make it to work and the following exception shows up:
                [ERROR] Uncaught exception escaped
                java.lang.ClassCastException: com.smartgwt.client.widgets.grid.ListGridRecord cannot be cast to com.smartgwt.client.widgets.tile.TileRecord at com.smartgwt.client.widgets.tile.TileRecord.getOrCreateRef(TileRecord.java:69) at com.smartgwt.client.data.DataSource.processResponse(Native Method) at mm.ui.client.AssetsDataSource$1.onSuccess(AssetsDataSource.java:52) at mm.ui.client.AssetsDataSource$1.onSuccess(AssetsDataSource.java:1)
                at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:215) at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl(Request.java:254) at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch(Request.java:226)
                at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:217)
                at com.smartgwt.client.widgets.BaseWidget.draw(Native Method) at mm.ui.client.MainEntryPoint.onModuleLoad(MainEntryPoint.java:138)

                More details are in this thread
                http://forums.smartclient.com/showthread.php?t=5086
                Any idea/comment? Thanks!
                This is possible, all you have to do is remove all references to ListGridRecord in the GWTRPCDataSource and replace it with Record, Also you will need to change the populateRecord implementation to return the Record (and abstract class).

                Next thing you have to do is in the populateRecord implementation ie: your data source class, you will need to cast your Record to what ever you want ie: ListGridRecord, TileRecord, TreeRecord, actually anything that implements the Record interface.

                ie:
                TileRecord r = TileRecord.getOrCreateRef(record.getJsObj());
                Hope this helps, anyone trying to do GWTRPCDataSource implementations.

                Please see attached the GWTRPCDataSource file for what to do with getting rid of references to ListGridRecord and changing it to Record.
                Attached Files

                Comment


                  #98
                  Originally posted by CharlesAbetz
                  This is possible, all you have to do is remove all references to ListGridRecord in the GWTRPCDataSource and replace it with Record, Also you will need to change the populateRecord implementation to return the Record (and abstract class).
                  Yes, this is the right thing to do.

                  Comment


                    #99
                    error bitblaster example

                    hi, i able to run bitblaster testadvdatasource.zip example, but on hosted mode, i get some error. pls have a look at screen shot
                    Attached Files

                    Comment


                      TreeGrid lazy load

                      Hi,
                      Here is my attempt to lazy load a tree using the GwtRpcDataSource (great job btw!). Not the cleanest code, but it works. Hope it helps

                      Code:
                      	public class FoldersDataSource extends GwtRpcDataSource {
                      
                      		private static final String NAME_FIELD = "name";
                      
                      		public FoldersDataSource() {
                      			setID("folders");
                      			setTitle("Dossiers");
                      			DataSourceTextField nameField = new DataSourceTextField(NAME_FIELD, "Nom", 128);
                      			
                      			// folder_id = primary key
                      			DataSourceIntegerField folderIdField = new DataSourceIntegerField(ID_FIELD, "Folder Id");
                      			folderIdField.setPrimaryKey(true);
                      			folderIdField.setRequired(true);
                      			
                      			// parent_id = foreign key
                      			DataSourceIntegerField folderParentIdField = new DataSourceIntegerField(PARENT_ID_FIELD, "Parent Id");
                      			folderParentIdField.setRequired(true);
                      			folderParentIdField.setForeignKey(ID_FIELD);
                      			folderParentIdField.setRootValue("0");
                      			
                      			setFields(nameField, folderIdField, folderParentIdField);
                      		}
                      
                      		@Override
                      		protected void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
                      			int parentId = 0;
                      			try {
                      				// get the id of node to open. Strangely, can't use getAttributeAsInt, fails for the root id
                      				parentId = Integer.parseInt(request.getCriteria().getAttribute(PARENT_ID_FIELD));
                      			}
                      			catch(RuntimeException e) {
                      				GWT.log("Not a number", e);
                      			}
                      			
                      			FilesServiceAsync filesService = FilesServiceAsync.Util.getInstance();
                      			filesService.getSubFolders(parentId, new AsyncCallback<Folder[]>() {
                      
                      				public void onFailure(Throwable arg0) {
                      					response.setStatus(RPCResponse.STATUS_FAILURE);
                      					processResponse(requestId, response);
                      				}
                      
                      				public void onSuccess(Folder[] folders) {
                      					Record[] records = new Record[folders.length];
                      					for(int i = 0; i < records.length; i++) {
                      						TreeNode treeNode = new TreeNode();
                      						Folder folder = folders[i];
                      						treeNode.setAttribute(ID_FIELD, folder.getId());
                      						treeNode.setAttribute(PARENT_ID_FIELD, folder.getParentId());
                      						treeNode.setAttribute(NAME_FIELD, folder.getName());
                      						records[i] = treeNode;
                      					}
                      					response.setData(records);
                      					processResponse(requestId, response);
                      				}
                      			});
                      		}
                      Please tell me if something is awfully wrong! :)

                      Comment


                        error when running bitblaster example?

                        did anyone get error in hosted mode when running bitblaster example ?

                        WARN] Malformed JSNI reference 'constructor'; expect subsequent failures
                        java.lang.NoSuchFieldError: constructor
                        at com.google.gwt.dev.shell.CompilingClassLoader$DispatchClassInfoOracle.getDispId(CompilingClassLoader.java:122)
                        at com.google.gwt.dev.shell.CompilingClassLoader.getDispId(CompilingClassLoader.java:574)
                        at com.google.gwt.dev.shell.mac.WebKitDispatchAdapter.getField(WebKitDispatchAdapter.java:68)
                        at org.eclipse.swt.internal.carbon.OS.ReceiveNextEvent(Native Method)
                        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2909)
                        at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
                        at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
                        at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
                        at com.google.gwt.dev.GWTShell.main(GWTShell.java:140)

                        Comment


                          Those warnings can be ignored. An issue has been reported for it, and these warnings should disappear with GWT 2.0, when OOPHM (out of process hosted mode) is supported.

                          Comment


                            grid shows no data

                            I don;t the see the data inside Grid, I see only the Header fields.
                            here my client code

                            public void onModuleLoad() {


                            // TODO Auto-generated method stub
                            TestDataSource myDataSource = new TestDataSource();

                            final ListGrid listGrid = new ListGrid();
                            //listGrid.setAutoFetchData(true);
                            listGrid.setShowFilterEditor(true);
                            listGrid.setShowAllRecords(false);
                            listGrid.setAlternateRecordStyles(true);
                            listGrid.setFilterOnKeypress(false);
                            listGrid.setDataPageSize(60);
                            listGrid.setWidth100();
                            listGrid.setHeight("*");
                            listGrid.setCanEdit(true);
                            listGrid.setEditEvent(ListGridEditEvent.CLICK);
                            listGrid.setEditByCell(true);

                            final FilterBuilder filterBuilder = new FilterBuilder();
                            //filterBuilder.setTopOperatorAppearance(TopOperatorAppearance.RADIO);

                            IButton filterButton = new IButton("Filter");
                            filterButton.setOverflow(Overflow.CLIP_V);

                            filterButton.addClickHandler(new ClickHandler() {
                            public void onClick(ClickEvent event) {
                            listGrid.invalidateCache();
                            listGrid.fetchData(filterBuilder.getCriteria());
                            }
                            });

                            filterBuilder.setDataSource(myDataSource);
                            listGrid.setDataSource(myDataSource);
                            listGrid.fetchData();
                            //listGrid.fetchData(filterBuilder.getCriteria());
                            //VStack vStack = new VStack(10);
                            VLayout vStack = new VLayout();
                            vStack.setWidth100();
                            vStack.setHeight100();

                            vStack.addMember(filterBuilder);
                            vStack.addMember(filterButton);
                            vStack.addMember(listGrid);

                            vStack.draw();

                            }

                            }

                            I tried both the options listGrid.setAutoFetchData(true); & listGrid.fetchData();

                            Pls help.
                            Thanks


                            Originally posted by alius
                            Hi Joe,

                            Either you have to manually call grid.fetchData () or you have to set grid.setAutoFetchData (true).

                            Aleksandras

                            Comment


                              Originally posted by ynaik
                              I don;t the see the data inside Grid, I see only the Header fields.
                              here my client code

                              public void onModuleLoad() {


                              // TODO Auto-generated method stub
                              TestDataSource myDataSource = new TestDataSource();

                              final ListGrid listGrid = new ListGrid();
                              //listGrid.setAutoFetchData(true);
                              listGrid.setShowFilterEditor(true);
                              listGrid.setShowAllRecords(false);
                              listGrid.setAlternateRecordStyles(true);
                              listGrid.setFilterOnKeypress(false);
                              listGrid.setDataPageSize(60);
                              listGrid.setWidth100();
                              listGrid.setHeight("*");
                              listGrid.setCanEdit(true);
                              listGrid.setEditEvent(ListGridEditEvent.CLICK);
                              listGrid.setEditByCell(true);

                              final FilterBuilder filterBuilder = new FilterBuilder();
                              //filterBuilder.setTopOperatorAppearance(TopOperatorAppearance.RADIO);

                              IButton filterButton = new IButton("Filter");
                              filterButton.setOverflow(Overflow.CLIP_V);

                              filterButton.addClickHandler(new ClickHandler() {
                              public void onClick(ClickEvent event) {
                              listGrid.invalidateCache();
                              listGrid.fetchData(filterBuilder.getCriteria());
                              }
                              });

                              filterBuilder.setDataSource(myDataSource);
                              listGrid.setDataSource(myDataSource);
                              listGrid.fetchData();
                              //listGrid.fetchData(filterBuilder.getCriteria());
                              //VStack vStack = new VStack(10);
                              VLayout vStack = new VLayout();
                              vStack.setWidth100();
                              vStack.setHeight100();

                              vStack.addMember(filterBuilder);
                              vStack.addMember(filterButton);
                              vStack.addMember(listGrid);

                              vStack.draw();

                              }

                              }

                              I tried both the options listGrid.setAutoFetchData(true); & listGrid.fetchData();

                              Pls help.
                              Thanks
                              Thanks , It worked..

                              Comment


                                trouble sorting locally

                                I'm having trouble sorting locally with the TestAdvSourceExample.zip project, with SmartGWT 1.1 and GWT 1.6.4. I was wondering if someone could suggest an answer.

                                I have remote searches with sorting working, but even from the example, if I return fewer results than the data page size, everything sorts as a string, regardless of the actual type (integer, date, etc).

                                For example, I take the example and modify the TestServiceImpl to:

                                Code:
                                	static {
                                		list = new ArrayList<TestRecord>();
                                		TestRecord record;
                                		for (int i = 1; i <= 40; i++) {
                                			record = new TestRecord();
                                			record.setId(i);
                                			record.setName("Name " + i);
                                			record.setDate(new Date(200 + i, 1, 1) );
                                			list.add(record);
                                		}
                                	}
                                And sorting doesn't work anymore (returning only 40 items lets it go into client-side sorting, I think). To be clear, it sorts, but it sorts everything as a string, so 11 is considered less than 4, for example.

                                I tried in the entry point to add:

                                Code:
                                                ListGridField[] fields = new ListGridField[3];
                                		fields[0] = new ListGridField("id", "ID");
                                		fields[0].setType(ListGridFieldType.INTEGER);
                                		
                                		fields[1] = new ListGridField("name", "name");
                                		fields[1].setType(ListGridFieldType.TEXT);
                                		
                                		fields[2] = new ListGridField("date", "Date of Birth");
                                		fields[2].setType(ListGridFieldType.DATE);
                                		
                                		listGrid.setFields(fields);
                                ...to no avail. I have also tried adding sort normalizers and they don't get called, it seems.

                                Anyone have any suggestions? Am I going from the wrong example, or missing something silly?

                                Much thanks in advance,

                                jd
                                Last edited by jdanzer; 22 Jun 2009, 17:12.

                                Comment

                                Working...
                                X