Announcement

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

    Originally posted by mnenchev
    Hi, ynaik. I attached you sample code (just .java files). Home it helps you. I didn't tested, but it should work. If you find any bugs, or errors let me know. Only executeAdd method is implemented, but the others are in the same manner. If you improve the code paste it here :).
    Download from here : http://rapidshare.com/files/28652421...ample.zip.html

    All you have to do is to implement SmartGWTDataConvertor for each dto you want to use and create ds for it like this:
    Code:
    final SmartGWTDataSource<TestDTO, SmartGWTDataConverter<TestDTO>, DataServiceAsync<TestDTO>> ds = 
    			new SmartGWTDataSource<TestDTO, SmartGWTDataConverter<TestDTO>, DataServiceAsync<TestDTO>>(new TestDataConverter(), ServiceUtils.getTestServiceAsync(), RecordType.GRID);
    Thanks a ton, I will surely upload the code in case i improve it.
    I don;t have access to download it now, will try this at home.
    Thanks a lot.

    Comment


      Originally posted by ynaik
      Thanks a ton, I will surely upload the code in case i improve it.
      I don;t have access to download it now, will try this at home.
      Thanks a lot.

      Hi Mnenchev,

      I am not very clear about the SmartGWTDataConverter java class,
      which contains interface HasSmartGWTDataResource , this public interface must be defined in its own class isn't it ? how can we name it as SmartGWTDataConverter .java, hope i am not sounding stupid :)

      When I rename SmartGWTDataConverter.java to HasSmartGWTDataResource , it cannot be resolved to Type
      (R extends HasSmartGWTDataConverter, cannot to be resolved Type)
      Last edited by ynaik; 30 Sep 2009, 06:20.

      Comment


        Originally posted by ynaik
        Hi Mnenchev,

        I am not very clear about the SmartGWTDataConverter java class,
        which contains interface HasSmartGWTDataResource , this public interface must be defined in its own class isn't it ? how can we name it as SmartGWTDataConverter .java, hope i am not sounding stupid :)

        When I rename SmartGWTDataConverter.java to HasSmartGWTDataResource , it cannot be resolved to Type
        (R extends HasSmartGWTDataConverter, cannot to be resolved Type)

        Hi Mnenchev,

        Please ignore above comments, I noticed i was just a class name spell error.

        Comment


          Excuse me, it's my fault. I used notepad to write the code. HasSmartGWTDataResource == SmartGWTDataConverter. This class just transforms data (model <=> smart gwt record). You may also need add other methods (for treenodes for example). It's up to you :).
          I updated the archive, every thing should be ok now.
          Last edited by mnenchev; 30 Sep 2009, 07:30.

          Comment


            Originally posted by mnenchev
            Excuse me, it's my fault. I used notepad to write the code. HasSmartGWTDataResource == SmartGWTDataConverter. This class just transforms data (model <=> smart gwt record). You may also need add other methods (for treenodes for example). It's up to you :).
            I updated the archive, every thing should be ok now.
            What is the class GWTCriterion, PLZ? The compiler does not recognize that class, and even google was not helpful when I attempted to figure out where that class is from... Is there something missing from the archive of yours?

            I'm handling the operations within transformResponse and I am just unable to create even one ****in row in the treeGrid, even when I create random TreeNode (ignoring what my GWT-service has sent via AsyncCallback)... I tried addData(...) and even setTestData(...) which method-name BTW I find highly confusing (but I guess I must be missing something... again)
            No luck with TreeGrid. :(
            Last edited by jzaruba; 2 Oct 2009, 17:40.

            Comment


              Hi, yes my archive does not contain all the files. You can find this missing classes in the smart gwt rpc implementations. Please read the Thread at the beginning, there you can find url from where you can get the missing classes.
              As i said before, i didn't tested the code with tree grid, but this is not connected with what we are trying to achieve - generic ds for any visual component, that uses GWT-RPC. How you implement your tree grid functionality is your concern(I can't help you - i never needed to implement such functionality with smart gwt).
              Regards.

              Comment


                Originally posted by mnenchev
                Hi, yes my archive does not contain all the files. You can find this missing classes in the smart gwt rpc implementations. Please read the Thread at the beginning, there you can find url from where you can get the missing classes.
                As i said before, i didn't tested the code with tree grid, but this is not connected with what we are trying to achieve - generic ds for any visual component, that uses GWT-RPC. How you implement your tree grid functionality is your concern(I can't help you - i never needed to implement such functionality with smart gwt).
                Regards.
                OK, I will try to find another way.
                (I read the thread from the start, but there seem to be several approaches discussed so I'm kinda confused as for what is related to what...)
                Thanks anyways.
                Last edited by jzaruba; 5 Oct 2009, 19:53.

                Comment


                  Calendar Date Picker Position

                  my calender can view monthly only. How do i to set the Date Picker position to left hand side?

                  Comment


                    Originally posted by levi
                    I had the same problem. I found that it works by calling fetchData() directly on the datasource instead of on the listGrid. Also, it's only a problem in hosted mode.
                    Thanks, but i have problem with update my results after fetch with criteria. My service sends result, but after processResponse(requestId, response); doesn`t update UI. Next action after that is execute fetch without criteria. Do you have these problem?

                    Comment


                      Originally posted by BeezeR
                      Thanks, but i have problem with update my results after fetch with criteria. My service sends result, but after processResponse(requestId, response); doesn`t update UI. Next action after that is execute fetch without criteria. Do you have these problem?
                      Did you setData before calling processResponse?
                      in your onSuccess method you have to call
                      response.setData(updatedRecords);// this is collection of your updated/fetched //record(s)
                      processResponse(requestId, response);

                      Comment


                        Originally posted by mnenchev
                        Did you setData before calling processResponse?
                        in your onSuccess method you have to call
                        response.setData(updatedRecords);// this is collection of your updated/fetched //record(s)
                        processResponse(requestId, response);
                        Code:
                        public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
                                Object critObject = request.getCriteria().getAttributeAsObject(PilotCriteria.SEARCH_CRITERIA);
                                if (critObject != null) {
                                    getService().getAll(critObject, new AsyncCallback<List<IDTO>>() {
                                        public void onFailure(Throwable throwable) {
                                            response.setStatus(RPCResponse.STATUS_FAILURE);
                                            processResponse(requestId, response);
                                        }
                        
                                        public void onSuccess(List<IDTO> contractDTOs) {
                                            SC.say(contractDTOs.size() + " документ(-ов) найдено.");
                                            List<AbstractRecord> records = new ArrayList<AbstractRecord>();
                                            if (contractDTOs != null && contractDTOs.size() > 0) {
                                                for (IDTO document : contractDTOs) {
                                                    records.add(createRecord(document));
                                                }
                                            }
                                            response.setData(records.toArray(new AbstractRecord[]{}));
                                            response.setTotalRows(records.size());
                                            processResponse(requestId, response);
                                        }
                                    });
                                } else {
                                    getService().getAll(new AsyncCallback<List<IDTO>>() {
                                        public void onFailure(Throwable throwable) {
                                            response.setStatus(RPCResponse.STATUS_FAILURE);
                                            processResponse(requestId, response);
                                        }
                            
                                        public void onSuccess(List<IDTO> dataList) {
                                            List<AbstractRecord> records = new ArrayList<AbstractRecord>();
                                            if (dataList != null && dataList.size() > 0) {
                                                for (IDTO document : dataList) {
                                                    records.add(createRecord(document));
                                                }
                                            }
                                            response.setData(records.toArray(new AbstractRecord[]{}));
                                            response.setTotalRows(records.size());
                                            processResponse(requestId, response);
                                        }
                                    });
                                } 
                            }
                        Don`t work. If i debug the "onSuccess" with criteria service work good, but no changing on UI

                        Comment


                          What is this AbstractRecord?

                          Comment


                            Originally posted by mnenchev
                            What is this AbstractRecord?
                            Code:
                            public abstract class AbstractRecord extends ListGridRecord
                            This is my custom ListGridRecord which also contains my custom object and properties for displaying on UI

                            Comment


                              Originally posted by mnenchev
                              Can you upload this file again?

                              Comment


                                filtering won't work?

                                Hi,
                                So its a really long thread and probably missed something, but I thought I would toss it out there.

                                I'm trying to get filtering to work with GwtRpcDataSource with no luck. First some initial assumptions I'm going by (which may be completely wrong).

                                1. The latest and greatest GwtRpcDataSource base class is at http://code.google.com/p/smartgwt-extensions/source/browse/trunk/src/main/java/com/smartgwt/extensions/gwtrpcds/client/GwtRpcDataSource.java

                                2. There is nothing "GWT" specific in this implementation. It simply allows one to override the fetch,update,remove, and add operations to allow one to pass back any data. (Maybe AbstractDataSource?)

                                Either way when I add the autoFilterBox or even call ListGrid.fetchData(Criteria), I get no filtering nor do I get any calls to fetchData(...) allowing me to handle the criteria? Am I using a wrong file or am I missing something?

                                Codes is below. Thanks for a great framework and any help :

                                Code:
                                public class TestEntry implements EntryPoint {
                                
                                  @Override   
                                  public void onModuleLoad() {
                                    final ListGrid grid = new ListGrid();
                                    ListGridField lgf = new ListGridField("firstname", "First Name");
                                    ListGridField lgf2 = new ListGridField("lastname", "Last Name");
                                    grid.setShowFilterEditor(true);
                                    grid.setAutoFetchAsFilter(true);
                                    grid.setAutoFetchData(true);
                                    grid.setShowAllRecords(false);
                                    grid.setFields(lgf, lgf2);
                                    DataSource ds = new MyDS();
                                    grid.setDataSource(ds);
                                    RootPanel.get().add(grid);
                                  }
                                  
                                  public static class MyDS extends GwtRpcDataSource {
                                    
                                    @Override
                                    protected void executeAdd(String requestId, DSRequest request, DSResponse response) {
                                    }
                                
                                    @Override
                                    protected void executeRemove(String requestId, DSRequest request, DSResponse response) {
                                    }
                                
                                    @Override
                                    protected void executeUpdate(String requestId, DSRequest request, DSResponse response) {
                                    }
                                    
                                    @Override
                                    protected void executeFetch(String requestId, DSRequest request, DSResponse response) {
                                      GWT.log("Fetch", null);
                                      ListGridRecord[] records = new ListGridRecord[3];
                                      ListGridRecord lgr = new ListGridRecord();
                                      lgr.setAttribute("firstname", "John");
                                      lgr.setAttribute("lastname", "Smith");
                                      records[0] = lgr;
                                      lgr = new ListGridRecord();
                                      lgr.setAttribute("firstname", "Mike");
                                      lgr.setAttribute("lastname", "Smith");
                                      records[1] = lgr;
                                      lgr = new ListGridRecord();
                                      lgr.setAttribute("firstname", "Bill");
                                      lgr.setAttribute("lastname", "Roberts");
                                      records[2] = lgr;
                                      response.setData(records);
                                      response.setTotalRows(records.length);
                                      processResponse(requestId, response);
                                    }
                                  }
                                }

                                Comment

                                Working...
                                X