Announcement

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

  • wz2b
    replied
    RequestFactory DataSource

    Hi,

    I tried to modify the GwtRpc version of this into something that should work with RequestFactory. Just as a test I am displaying it in a ListGrid.

    I have gotten as far as it making a request to my server, but there are two problems:

    1) Why does it make the request TWICE?

    2) ... with the same ID?


    Code:
    00:37:57.596  [INFO] Transforming a request
    00:37:57.606  [INFO] Issue fetch request customerDataSource$6270
    00:37:57.696  [INFO] Transforming a request
    00:37:57.706  [INFO] Issue fetch request customerDataSource$6270
    00:37:57.815  [INFO] Module admin has been loaded
    00:37:57.987  [INFO] Creating a record for customer 1
    00:37:57.993  [INFO] Creating a record for customer 2
    00:37:57.997  [INFO] Creating a record for customer 3
    00:37:57.999  [INFO] Creating a record for customer 4
    00:37:58.002  [INFO] Returning 4 records
    00:37:58.006  [INFO] Processing request customerDataSource$6270
    00:37:58.009  [ERROR] 13:25:00.066:WARN:DataSource:customerDataSource:DataSource.processResponse(): Unable to find request corresponding to ID customerDataSource$6270, taking no action.
    00:37:58.065  [INFO] Creating a record for customer 1
    00:37:58.069  [INFO] Creating a record for customer 2
    00:37:58.074  [INFO] Creating a record for customer 3
    00:37:58.075  [INFO] Creating a record for customer 4
    00:37:58.077  [INFO] Returning 4 records
    00:37:58.079  [INFO] Processing request customerDataSource$6270
    00:37:58.082  [ERROR] 13:25:00.139:WARN:DataSource:customerDataSource:DataSource.processResponse(): Unable to find request corresponding to ID customerDataSource$6270, taking no action.
    A third problem is that, even though I return a Record [] with the results, they don't show up in the grid.

    Code:
    @Override
    protected Object transformRequest( DSRequest request ) {
    	GWT.log( "Transforming a request" );
    	String requestId = request.getRequestId();
    	DSResponse response = new DSResponse();
    	response.setAttribute( "clientContext", request.getAttributeAsObject( "clientContext" ) );
    	// Assume success
    	response.setStatus( 0 );
    	switch ( request.getOperationType() ) {
    		case FETCH:
    			executeFetch( requestId, request, response );
    			break;
    		case ADD:
    			executeAdd( requestId, request, response );
    			break;
    		case UPDATE:
    			executeUpdate( requestId, request, response );
    			break;
    		case REMOVE:
    			executeRemove( requestId, request, response );
    			break;
    		default:
    			// Operation not implemented.
    			break;
    	}
    	return request.getData();
    }
    Code:
    private void executeFetch( final String requestId, final DSRequest request, final DSResponse response ) {
    	GWT.log( "Issue fetch request " + requestId );
    	final CustomerRequestFactory.CustomerRequest rfreq = requestFactory.custRequest();
    
    	int startRow = request.getStartRow();
    	int endRow = request.getEndRow();
    
    	rfreq.fetchCustomers( startRow, endRow ).fire( new Receiver<List<CustomerProxy>>() {
    
    		@Override
    		public void onSuccess( List<CustomerProxy> customers ) {
    			List<Record> records = new ArrayList<Record>();
    			for ( CustomerProxy customer : customers ) {
    				GWT.log( "Creating a record for customer " + customer.getId() );
    				ListGridRecord r = new ListGridRecord();
    					
    				r.setAttribute( "id", customer.getId() );
    				r.setAttribute( "name", customer.getCustomerName() );
    				records.add( r );
    			}
    			Record[] arr = new Record[records.size()];
    			GWT.log( "Returning " + arr.length + " records" );
    			response.setData( records.toArray( arr ) );
    			GWT.log( "Processing request " + requestId );
    			processResponse( requestId, response );
    		}
    			
    		@Override
    		public void onFailure(ServerFailure error) {
    			GWT.log("FAIL: " + error.getMessage());
    			response.setStatus( RPCResponse.STATUS_FAILURE );
    			processResponse( requestId, response );
    		}
    	} );
    }
    Code:
    @Inject
    public AdminHome(CustomerDataSource ds) {
    	GWT.log("initializing home");
    		
    	this.ds = ds;
    	layout = new VLayout(15);
    	initWidget(layout);
    		
    	grid = new ListGrid();
    		
    	grid.setAlwaysShowEditors(true);
    	grid.setWidth(550);
    	grid.setHeight(224);
    	grid.setShowAllRecords(true);
    	grid.setCellHeight(22);
    		
    	grid.setDataSource(ds);
    	layout.addChild(grid);
    		
    	grid.fetchData();
    }

    Leave a comment:


  • joaoahf
    replied
    ComboBox values inside GridtextField

    Hi all,

    I'm using the GenericRPCDataSource implementation presented on this thread.

    I need to have cell editing displaying all possible values for a specific cell in a combobox, similar to "Continent" field in http://www.smartclient.com/smartgwt/showcase/#grid_editing_cell


    What is the most elegant way to do this? I'm thinking to call an RPC which will get all the combobox possible values in a Map (possible_values) and then use:

    DataSourceTextField itemType = new DataSourceTextField("itemType", "Item type");
    itemType.setValueMap(possible_values);


    Thank you very much for your time.

    Leave a comment:


  • bugmenot
    replied
    Did I make the question too difficult to understand or is there another problem? I would think there would be more people using this implementation the way I want to use it, though I could be wrong.

    Leave a comment:


  • gImperator
    replied
    Problem with saveAllEdits

    I have used this implementation and I managed to make everything work... well, almost :) I set my ListGrit to disable automatic saving and use a button to initiate a "mass update". I'm using saveAllEdits and for the most part, it works as expected. for every updated record, the update method is being called but the problem arises after finishing the method call - SmartGWT throws an exception that a list index is out of bounds. What that means in short is that, for some reason, that the edited values are unavailable in the grid so only unedited values will be shown. Also, a window refresh loads the correct values.

    My question comes down to: what am I missing with saveAllEdits?
    Alternatively, should I save the edits in some other way?

    As a bonus :) is there a way to do a batch update?

    Leave a comment:


  • jlpuffe
    replied
    I tried setting parentId the following way:

    copyValues(ManagerRecord from, ListGridRecord to) {
    to.setAttribute("parentId", from.getId());
    }


    but when I check this attribute as you have shown below it is always a null even though I've selected a parent node and tried to expand it. I've made sure there is a value actually being stored and there is. But I can't seem to retrieve it.

    Also..I define the parentId field as follows:

    DataSourceIntegerField parentIdField = new DataSourceIntegerField("parentId", "parentId");
    parentIdField.setRequired(true);
    parentIdField.setHidden(true);
    addField(parentIdField);

    Any ideas why parentId might be null on the executeFetch() method when checking for it using the code DSRequest.getCriteria().getAttribute("parentId");

    Thanks in advance!

    Originally posted by mouchard
    I'll reply to myself.

    After reading a little bit more the documentation, I can see that the Id of the selected node is set into the DSRequest within a criteria which is called "parentId".

    Here is a piece of the GenericGwtRpcDataSource class

    Code:
    	@Override
    	protected void executeFetch(final String requestId,
    			final DSRequest request, final DSResponse response) {
    		
    		//The ResultTree's DSRequests ask for the immediate children of a node only (by specifying parentId in the criteria).
    		String parentId = request.getCriteria().getAttribute("parentId");
                    //... take the parentId to pass it to the fetch method...
    		
    		serviceAsync.fetch(parentId,
    				new AsyncCallback<List<D>>() {
    			public void onFailure(Throwable caught) {
    				response.setStatus(RPCResponse.STATUS_FAILURE);
    				processResponse(requestId, response);
    			}
    
    			public void onSuccess(List<D> result) {
    				List<R> records = new ArrayList<R>();
    				for (D data : result) {
    					R newRec = getNewRecordInstance();
    					copyValues(data, newRec);
    					records.add(newRec);
    				}
    
    				response.setData(records.toArray(new Record[records.size()]));
    				processResponse(requestId, response);
    			}
    		});
    	}

    Leave a comment:


  • Tasmit
    replied
    I've found out that there was deserialization problem.
    My Entity has only Long, String and Date parameters + implements Serializable, IsSerializable.
    I tryied to find the reason - in some forums there were an opinion, that GWT cannot deserialize a class with an @Entity annotation.
    Now, I'm searching for solving this problem (without adding Gilead, dozer etc).

    Leave a comment:


  • ssieb
    replied
    You didn't check that line I pointed out on the client. It would also help if you posted the rest of the code that is involved here. (e.g. the client side handling, the caller, the server side)

    Leave a comment:


  • Tasmit
    replied
    I've checked, that DAO returns correct List<ProjectInfo> (DB request works fine, returned value is correct).
    I've printed the returned list to the console (before return) - it's ok.
    There were no errors.

    Leave a comment:


  • ssieb
    replied
    Have you checked for any error output on the server side? You could also use a debugger and find out what the client is getting at:
    Code:
    com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:237)

    Leave a comment:


  • Tasmit
    replied
    I've changed SmartGWT 2.4 to SmartGWT 3.0.

    Error message changed, but it's not more helpful for me:
    Code:
    08:39:02.978 [ERROR] [app] 08:39:02.962:WARN:RPCManager:Server returned FAILURE with no error message., response: {clientContext: Obj, status: -1, context: undef, startRow: 0, endRow: 0, totalRows: 0}
    com.smartgwt.client.core.JsObject$SGWT_WARN: 08:39:02.962:WARN:RPCManager:Server returned FAILURE with no error message., 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.templates.GenericGwtRpcDataSource$1.onFailure(GenericGwtRpcDataSource.java:136)
        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.GeneratedMethodAccessor41.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)

    Leave a comment:


  • Tasmit
    replied
    Hi, all!

    GWT: 2.4.0
    SmartGWT: 2.4 (simple, not pro/EE - I'm just a hobbist).
    Google Chrome: 17.0.963.46 (the latest version)

    I tried to make simple GwtRpcDataSource and was faced out with problems.
    In trying to resolve them, I've rewrote everything to GenericGwtRpcDataSource.

    I've managed to found the reason of the first problem (stupid mistake which isn't related to GwtRpcDataSource and gwt at all).

    At present - everything is worked, but... only if there are no data in DB. :(
    If I have at least 1 record in DB - it fails with error message.

    Code:
    00:18:34.290 [ERROR] [app] 00:18:34.268: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: 00:18:34.268: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.templates.GenericGwtRpcDataSource$1.onFailure(GenericGwtRpcDataSource.java:134)
        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)
    My service:
    Code:
    	public List<ProjectInfo> fetch() {
    		System.out.println("[Server] ProjectInfoServiceImpl->fetch()...");
    		return getVersionDao().findAll();
    	}
    Sysout is printing, hibernate (I use it in DAO) connects to the DB and retrieves the data.
    My object contains only long, String and Data (without lazy loading etc.), but I've tried it also with LightEntity (Gilead).
    getVersionDao().findAll() returns List<ProjectInfo>.

    In console: no errors, last message - hibernate log message of successful DB request.
    In GWT log - the above message.

    What can be the reason of this error?

    One more problem - I use com.smartgwt.client.widgets.grid.ListGridRecord as Record.
    According to the docs, it has to have getAttributeAsLong method, but it hasn't.
    So, what should I use for long fields? (for DataSource and for ListGridRecord)?

    Leave a comment:


  • ezlourido
    replied
    is possible to perform paging by an object of smartGWT listgrid, THROUGH genericgwtrpcdatasource??, as I can do??

    Leave a comment:


  • dwestb
    replied
    Nikd,

    What were the project options/parameters that you changed?

    Thanks,

    David

    Leave a comment:


  • Shoonya
    replied
    Hi Morbat,

    Can you provide any link/hint/code for implementing server side filtering.
    I saw an old post from bitblaster in different thread, but all the places where he/she uploaded code are dead now.

    Leave a comment:


  • mouchard
    replied
    So far I'm able to retrieve all information using generic class provided by marbot.
    I'm also using load on demand but the next step is :

    when expanding a node having children that are the latest level in the tree (having no children) I would like them to appear without the little "+" and with an other icon than a folder.

    Is there a simple way to do that?

    Thanks ;-)

    Leave a comment:

Working...
X