TestAdvDataSource.zip file
Hi!
How can I get TestAdvDataSource.zip file as I'm learning smartgwt datasource?
Plz help.
Thanks
Announcement
Collapse
No announcement yet.
X
-
Hi ,
i find what was a problem,
problem was in class RadnikDS
i forgot to add response:
Code:response.setData (list); response.setTotalRows (result.size ()); processResponse (requestId, response);
Leave a comment:
-
Leave a comment:
-
How to handle associations?
Hi all,
Really good example of GWT-RPC datasource implemetation!
My problem is to show data in listgrid ?? I using GWT with Hibernate...gilead based solution...
My domain objects have relations @ManytoOne and @OneToMany implement as "javax.persistence annotations'
Hibernate query execute fine, but datasource don't show values to listgrid?!?!
http://forums.smartclient.com/showthread.php?t=4814&page=7
My problem is very similar as @mivola
I don't know where i making mistake,i'm really new in GWT,could you help me please???
Leave a comment:
-
Read the Tree Databinding overview - one obvious problem is that you have no foreignKey declaration at all.
Leave a comment:
-
Originally posted by IsomorphicSince you're new, please note that we now strongly recommend against using GWT-RPC, for reasons listed in the FAQ.
[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();
}
Leave a comment:
-
Originally posted by IsomorphicSince you're new, please note that we now strongly recommend against using GWT-RPC, for reasons listed in the FAQ.
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()); } }
Leave a comment:
-
Since you're new, please note that we now strongly recommend against using GWT-RPC, for reasons listed in the FAQ.
Leave a 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; } }
Leave a comment:
-
Has any body answers for the following question from earlierpost. a sample will be nice
Originally posted by fbrierI 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.
Leave a 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
Leave a 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.
Leave a 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
Leave a 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)
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}
Code:{[b]__gwt_ObjectId: 893[/b], clientContext: Obj, status: -1, context: undef, startRow: 0, endRow: 0, totalRows: 0}
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.
Leave a comment:
-
Originally posted by kimmieI'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.
Leave a comment:
Leave a comment: