Announcement

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

  • jzaruba
    replied
    Originally posted by kassec
    Hi,

    This is crazy topic about Gwt RPC !

    From what I read, almost everything has been writen except for one point about which I'd like to get community feedback.

    ...

    When fetching records, I will be able to extract the foreign key using
    Code:
    setAttribute("boss",entity.getBoss().getId());
    and I'll be able to create new Record s without trouble.

    I'd be happy to read about your options ...
    I'm not sure how this could possibly work without sending all the data (person, its boss, his boss, his boss, etc... whole db?) in one request. Otherwise your getBoss() call (which IMO happens on the client side) would either always return null OR it would have to make another (synchronous!) request to fetch the boss entity from the server.

    My understanding is that lazy many-to-one relations do not cope with the GWT concept.
    (I would be happy should anyone correct me on this.)
    Last edited by jzaruba; 28 Oct 2009, 14:04.

    Leave a comment:


  • rfa
    replied
    Hi mnenchev

    Originally Posted by mnenchev
    Download from here :http://rapidshare.com/files/28695615...ample.zip.html
    Can you upload this file again?

    Many Thanks
    Last edited by rfa; 23 Oct 2009, 01:13.

    Leave a comment:


  • bugmenot
    replied
    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?
    maybe this is your problem...
    Originally posted by jzaruba
    When implementing REMOVE (or any non read-only operation) do not forget to mark exactly one of your DataSourceFields as primaryKey.
    Without that your DSResponse.getData() will return empty array.

    Leave a comment:


  • kassec
    replied
    Hi,

    This is crazy topic about Gwt RPC !

    From what I read, almost everything has been writen except for one point about which I'd like to get community feedback.

    How do you manage DTOs (or Entities) having relationship with "complex" objects ?

    I mean, imagine a simple tree structure :

    Code:
    class Person {
      private Integer id;
      private String name;
      private Person boss;
    }
    For the mapping, I will certainly do something like :

    Code:
    	DataSourceField field;
    
    	field = new DataSourceIntegerField("id");
    	field.setPrimaryKey(true);
    	field.setRequired(false);
    	field.setCanEdit(false);
    	addField(field);
    
    	field = new DataSourceTextField("name");
    	field.setRequired(true);
    	addField(field);
    
    	field = new DataSourceIntegerField("boss");
    	field.setRequired(false);
    	field.setForeignKey("id");
    	addField(field);
    When fetching records, I will be able to extract the foreign key using
    Code:
    setAttribute("boss",entity.getBoss().getId());
    and I'll be able to create new Record s without trouble.

    My concern is about rebuilding the entity on add/update requests since I'll only be given the id and Person.setBoss(Person p) wants a Person, not an Integer ... Even worst, if I imagine trying to retrieve a Person record/object using the id (DataSource.fetchData()), this is done asynchronously which is not acceptable.

    I'd be happy to read about your options ...

    Leave a comment:


  • mschulman
    replied
    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);
        }
      }
    }

    Leave a comment:


  • LDevil
    replied
    Originally posted by mnenchev
    Can you upload this file again?

    Leave a comment:


  • BeezeR
    replied
    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

    Leave a comment:


  • mnenchev
    replied
    What is this AbstractRecord?

    Leave a comment:


  • BeezeR
    replied
    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

    Leave a comment:


  • mnenchev
    replied
    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);

    Leave a comment:


  • BeezeR
    replied
    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?

    Leave a comment:


  • almond
    replied
    Calendar Date Picker Position

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

    Leave a comment:


  • jzaruba
    replied
    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.

    Leave a comment:


  • mnenchev
    replied
    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.

    Leave a comment:


  • jzaruba
    replied
    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.

    Leave a comment:

Working...
X