Announcement

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

  • dimavin
    replied
    JavaScriptException: (null) in DataSource.processResponse after switching to GWT2.0

    Hi,

    My simple datasource test (based on alius code) stopped working after switching to GWT2.0, both for smartgwt 1.3 and 2.0.
    My client view contains a ListGrid and a DynamicForm, both bound to the same datasource.
    After adding a record via the form, SimpleGwtRPCDS.executeAdd() gets executed and the call back onSuccess() throws when calling
    processResponse(requestId, response);
    This is not happening if the ListGrid is removed or not connected to the datasource.

    Thanks,
    Dmitriy

    09:29:18.133 [ERROR] [ds0604] Uncaught exception escaped
    com.google.gwt.core.client.JavaScriptException: (null): null
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    at com.smartgwt.client.data.DataSource.processResponse(DataSource.java)
    at my.client.SimpleGwtRPCDS$2.onSuccess(SimpleGwtRPCDS.java:122)
    at my.client.SimpleGwtRPCDS$2.onSuccess(SimpleGwtRPCDS.java:1)
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
    Attached Files

    Leave a comment:


  • dindeman
    replied
    Hi sunnyl,

    Just used your GwtRpcDataSource interface and it worked perfectly. Thank you for posting this example a while ago.

    Cheers,
    - Luc

    Leave a comment:


  • sunnyl
    replied
    Hi junieboy,

    Seeing GWT 2.0 and SmartGWT 2.0 were just released recently I've checked that it works with these new versions. Download it again with the same link (http://www.group1solutions.com.au/sunny/smartgwt/datasource-test.zip)

    The project was created in Eclipse 3.5, JDK 1.6(u17?), now GWT 2.0 and SmartGWT 2.0. You'll need to drop the 2.0 JARs into the WEB-INF/lib directory after you've imported the project into Eclipse. I think Eclipse will automatically put the gwt-servlet JAR into WEB-INF/lib if your project references GWT 2.0.

    I think it is the way to go if you want to keep using GWT-RPCs (especially if you're comfortable with them, that, and SmartGWT EE isn't being used). Essentially the system flow becomes:

    GUI<->DataSource<->GWT-RPC<->GWT Service Implementations<->DB

    I've started a project taking this approach using a number of databound components (ListGrid and combos mostly) and its worked out well so far.

    Comparing this to my previous project where I used Stores in GWT-Ext, I think one complexity has been traded for another, although the SmartGWT approach to things is much cleaner, and having to use GwtRpcDataSource does force you to have a cleaner implementation IMO.

    regards
    Sunny


    Originally posted by junieboy
    Hi Sunnyl,

    Thanks so much for your response. May I ask the versions of
    - JDK
    - GWT
    -SmartGWT

    you are using in the example you created? :-)

    Btw, is this the way to go if I want to populate a ListGrid with data coming from an Oracle database? I am currently evaluating how to implement this using SmartGWT 2.0 with GWT 2.0 only without the usage of SmartGWT EE. Thanks so much!

    Regards.

    Leave a comment:


  • junieboy
    replied
    GWT-RPC DataSource implementation

    Hi Sunnyl,

    Thanks so much for your response. May I ask the versions of
    - JDK
    - GWT
    -SmartGWT

    you are using in the example you created? :-)

    Btw, is this the way to go if I want to populate a ListGrid with data coming from an Oracle database? I am currently evaluating how to implement this using SmartGWT 2.0 with GWT 2.0 only without the usage of SmartGWT EE. Thanks so much!

    Regards.
    Last edited by junieboy; 25 Dec 2009, 19:25.

    Leave a comment:


  • sunnyl
    replied
    Have a look at post #205, and see if it helps you :)

    Originally posted by junieboy
    Hi Alexandras/Isomorphic,

    I was following through your post
    http://forums.smartclient.com/showthread.php?t=4814

    and if I'm not mistaken, I tried pouring over the SmartGWT 2.0 jars and it seems that the required changes have already been included.

    As I'm new to this, could I ask you for complete sample codes on the usage of the GWT-RPC DataSource?

    Thanks!

    Leave a comment:


  • junieboy
    replied
    GWT-RPC DataSource sample

    Hi Alexandras/Isomorphic,

    I was following through your post
    http://forums.smartclient.com/showthread.php?t=4814

    and if I'm not mistaken, I tried pouring over the SmartGWT 2.0 jars and it seems that the required changes have already been included.

    As I'm new to this, could I ask you for complete sample codes on the usage of the GWT-RPC DataSource?

    Thanks!

    Leave a comment:


  • tullurir
    replied
    Question regarding paging

    Hi:

    I am trying to understand how paging is supposed to work in a ListGrid using TestAdvDataSource.zip code. I have the following simple issue that I am not able to resolve.

    My table in the database has 110 records and I do not want to fetch all of them at once into the ListGrid. I suppose using the pattern in TestAdvDataSource code base will enable the ListGrid to fetch in batches, say 60 at a time as one scrolls through the grid.

    I have made server side code to take the start and end row parameters and therefore I get only 60 records at a time. However, what I am seeing is that in the onSuccess method of the DataSource object a new rpc call is fired to the server right after the processResponse(requestId, response) line of the code when the first batch of records are fetched. As a result, the second rpc call brings back the remaining 50 records from the database and overlaying the data in the grid with the 50 records.

    However, I am under the impression that the second batch of the records will not be fetched by the listGrid until you scroll down. Is my understanding right? If so, could you please let me know what I might be doing wrong?

    Your help is greatly appreciated.

    Thanks
    Ram

    Code:
    @Override
    public void onSuccess(FetchResult<DataRecord> dataRecordSet)
    {
       response.setData(dataRecordSet.getFetchedList());
       response.setStartRow(dataRecordSet.getStartRow());
       response.setEndRow(dataRecordSet.getEndRow());
       response.setTotalRows(dataRecordSet.getTotalRows());
       processResponse(requestId, response);
    }
    Last edited by tullurir; 1 Dec 2009, 06:57.

    Leave a comment:


  • rfa
    replied
    DataSource and DatasourceField

    Hi,

    I try to create GWT-RPC DataSource and i want to define the DatasourceField
    after the first "AsyncCallback fetch", (from sql meta values) :
    DataSourceTextField(ColumnName , ColumnLabel)

    but i get error message :
    Code:
    Fields cannot be added to a DataSource after the underlying component
    has been created
    I understand this message but i need help for a implementation

    Thanks

    Regis

    Leave a comment:


  • avthart
    replied
    Issue

    Originally posted by nabla52
    Hi

    Isomorphic told me to post my query in this thread, so here it:

    When a validation error occurs from my (GWT) server, I do the following (as an example):

    <code>
    final Map<String, String> fieldErrors = new HashMap<String, String>();
    fieldErrors.put("name", "This should be my error message");
    final DSResponse response = new DSResponse();
    response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
    response.setStatus(DSResponse.STATUS_VALIDATION_ERROR);
    response.setErrors(fieldErrors);
    processResponse(request.getRequestId(), response);
    </code>

    This works with a DynamicForm i.e. the field "name" gets an error icon and you can hover over it and the message is shown. However when using a ListGrid the error message shown against the column (named 'name' and which gets an error icon) is always "undefined" !!! Why? If I explicitely use ListGrid.setFieldError(row, "name", "This should be my error message") the ListGrid displays the right message! It seems that DSResponse does not hand back the error message to the ListGrid (but it does to the DynamicForm)!

    Can you help. Many thanks
    Hi nabla52,

    Did you create an issue for this?
    I have the same problem using a ListGrid.

    The workaround you provided works but it would be nice if the method
    DSResponse.setErrors(Map errors) also works with a ListGrid.

    Thanks.

    Leave a comment:


  • sunnyl
    replied
    Hi everyone, after spending a couple of hours wrapping my head around everything I've made a small example using GwtRpcDataSource.

    All it does is populate ComboBoxItems by:

    1) Passing the data plain as a String[][] using GWT-RPC and building the DataSource at the client side. (I saw this approach made in a document by Sanjiv about migrating to SmartGWT)

    2) Extending GwtRpcDataSource and implementing the fetch method.

    Here it is

    Its an Eclipse project which has the Google Plugin for Eclipse installed. The SmartGWT jar needs to be added to the build path.

    I made it simple enough for me to learn from, so I hope it helps another newbie like me out there!

    Leave a comment:


  • sjivan
    replied
    Hi Alius,
    The idea is that all DataBound components should actually work with the generic Record type. Users can use widget specific record types but they should be interchangeably be able to used to display contents of other DataBound components. So the GwtRpcDataSource should really only be working at the "Record" level so that it can be used with any DataBoundComponent.

    Sanjiv

    Leave a comment:


  • alius
    replied
    Originally posted by noone123
    Using SmartGWT 1.3:

    I'm assuming that based on previous posts here that Record[] should indeed be a valid type for all DataBound components, so this is probably a bug in SmartGWT.
    Different UI components works with different kinds of records (ListGridRecord, TreeGridRecord etc.) and you have to provide correct record instance for specific UI component.

    Here is your corrected code:
    Code:
    Record[] list = new Record[result.getFetchedList().size()];
    for (int i = 0; i < list.length; i++)
    {
    	Record record = new ListGridRecord();
    //                                     ^^^^^^^^^^^^^^^
    	copyValues(result.getFetchedList().get(i), record);
    	list[i] = record;
    }
    response.setData(list);
    It is not a bug. Record is just parent for all record implementations (maybe it should be abstract?).
    If you want to have generic DS then you have to check calling component and based on it instantiate correct record implementation.

    Alius

    Leave a comment:


  • noone123
    replied
    SmartGWT Record[] ListGrid (and more?) bug...

    Originally posted by sjivan
    Hi Aleksandras,
    You're right, I'll change the API's to accept Record.

    Sanjiv
    Using SmartGWT 1.3:

    Code:
    Record[] list = new Record[result.getFetchedList().size()];
    for (int i = 0; i < list.length; i++)
    {
    	Record record = new Record();
    	copyValues(result.getFetchedList().get(i), record);
    	list[i] = record;
    }
    response.setData(list);
    The above code compiles, however it still does not work completely. Using for example a ListGrid object that is bound to the DataSource, the following error will be seen:

    Code:
    Uncaught JavaScript exception [java.lang.ClassCastException: com.smartgwt.client.data.Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord
     at com.smartgwt.client.widgets.grid.ListGridRecord.getOrCreateRef(ListGridRecord.java:91)
    I'm assuming that based on previous posts here that Record[] should indeed be a valid type for all DataBound components, so this is probably a bug in SmartGWT.

    I have not tested the other data bound components, it is possible this is the only one this happens with, but if this is part of a bug fix then I recommend checking the others as well.

    Leave a comment:


  • jzaruba
    replied
    Another pitfall with TreeGrid: Avoid using null as rootValue for foreignKey dataSourceField.
    Even though null is the default rootValue when you don't set it otherwise via myForeignKeyField.setRootValue it does not work with add-operation. (No problem with update or fetch.)

    Just set rootValue to 0 and translate zeroes back to nulls before saving the record.
    Last edited by jzaruba; 4 Nov 2009, 23:55.

    Leave a comment:


  • jzaruba
    replied
    UPDATE: transformRequest and processResponse seem to be the cure :)

    Has anyone made TreeGrid working with both primaryKey and foreignKey being Integer-fields?

    Code:
    DataSourceIntegerField employeeIdField = new DataSourceIntegerField("id", "Employee");
    employeeIdField.setPrimaryKey(true);
    
    DataSourceIntegerField bossIdField = new DataSourceIntegerField("bossId", "Reports to");
    bossIdField.setForeignKey("id");
    
    DataSourceTextField nameField = new DataSourceTextField("name", "Name");
    
    ...
    
    Record record = new ListGridRecord();
    // note data types of the attributes
    record.setAttribute("id", id); // Integer
    record.setAttribute("bossId", bossId); // Integer
    record.setAttribute("name", name); // String
    It seems to me that such Record simply does not work with the target treeGrid when being added from within transformResponse method, when added let's say from the DataSource constructor everything works fine...
    To get the record in the treeGrid via transformResponse I have to set its bossId attribut as a string instead of int, which creates complications elsewhere. (Because in db the 'bossId' field is obviously of the same type as the primary key 'id', both of them are Integers.)

    What is the proper pray of populating TreeGrid with data frmo GWT-RPC?
    Last edited by jzaruba; 28 Oct 2009, 17:49.

    Leave a comment:

Working...
X