Announcement

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

  • hakito
    replied
    With the current sample implementation it is not possible to update a primary key field. When trying to do this copyValues will throw NullPointerException.

    So how can i update primary key fields?

    Leave a comment:


  • marbot
    replied
    Server-side paging & sorting now supported by GenericGwtRpcDataSource

    Hi all

    Seeing that some of us had troubles getting server-side paging & sorting to work, I've added this functionality in GenericGwtRpcDataSource, as explained here:

    http://forums.smartclient.com/showth...4370#post44370

    The thread also contains a example project showing the functionality with a ListGrid.

    Feel free to have a look.

    cheers
    marbot

    Leave a comment:


  • fbrier
    replied
    ValuesManager and related DataSources

    I 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:


  • vinayakshukre
    replied
    Can somebody please look into this ?

    Can somebody please look into this ?
    Please help.

    Leave a comment:


  • vinayakshukre
    replied
    Thanks. It means my guess was right.

    Any way, I could get that example running with bit simple code as follows.

    Code:
    class MyEntryPoint{
    	final ListGrid countryGrid = new ListGrid();    
    	countryGrid.setShowAllRecords(false);
    	countryGrid.setDataPageSize(10);
    	countryGrid.setWidth(500);  
    	countryGrid.setHeight(200);  
    	final MyDataSource dataSource = new MyDataSource(greetingService);
    	countryGrid.setDataSource(dataSource);
    	countryGrid.setAutoFetchData(true);
    	RootPanel.get("r1").add(countryGrid);
    }
    
    class MyDataSource extends DataSource{
    	GreetingServiceAsync service = null;
    	
    	
    
    	
    	public MyDataSource(GreetingServiceAsync service){
    		super();
    		this.service = service ;
    		setID("abc");      
                              DataSourceField countryNameField = new DataSourceField("countryName", FieldType.TEXT, "Country");  
                              DataSourceField countryCodeField = new DataSourceField("countryCode", FieldType.TEXT, "Code");  
                              DataSourceField populationField = new DataSourceField("population", FieldType.INTEGER, "Population");
                              setFields(countryCodeField,countryNameField,populationField);    
                              setClientOnly(true);   
            
    	}
    	@Override
    	protected Object transformRequest(DSRequest dsRequest) {
    		final int iStart = dsRequest.getStartRow();
    		final int iEnd = dsRequest.getEndRow() ;
    		System.out.println("Request came to client code for start =  " + iStart + " " +  iEnd + " " + dsRequest.getRequestId());
    		final String requestId = dsRequest.getRequestId ();
                              final DSResponse response = new DSResponse ();
                              response.setAttribute ("clientContext", dsRequest.getAttributeAsObject ("clientContext"));
                              response.setStatus(0);
                              int iDiff = iEnd - iStart ;
                              ListGridRecord[] list = new ListGridRecord[iDiff];
                              for(int i = 0 , j = iStart ;j< iEnd;i++,j++){
            	                  list[i] = new ListGridRecord();
            	                  long time = System.currentTimeMillis();
            	                  list[i].setAttribute("countryName", "India " +j);
            	                  list[i].setAttribute("countryCode", "In_"+j);
            	                  list[i].setAttribute("population", time);
                              }
                              response.setData(list);
                              response.setStartRow(iStart);
    		response.setEndRow(iEnd);
    		response.setTotalRows(1000);
    		processResponse(requestId, response);
    		return dsRequest.getData();
    		
    	}
    	}
    This code works fine as it generates rows as requested by moving scrollbar of ListGrid. I was happy.

    Then I thought of replacing row generation logic with one rpc call.

    So my new code looked like :
    Code:
    protected Object transformRequest(DSRequest dsRequest) {
    		final int iStart = dsRequest.getStartRow();
    		final int iEnd = dsRequest.getEndRow() ;
    		System.out.println("Request came to client code for start =  " + iStart + " " +  iEnd + " " + dsRequest.getRequestId());
    		final String requestId = dsRequest.getRequestId ();
                              final DSResponse response = new DSResponse ();
                              response.setAttribute ("clientContext", dsRequest.getAttributeAsObject ("clientContext"));
                              response.setStatus(0);
                              int iDiff = iEnd - iStart ;
                              this.service.greetServer(iStart, iEnd, new AsyncCallback<ReportRow[]>(){
    
    			public void onFailure(Throwable caught) {
    				Window.alert("Error while fetching new rows");				
    			}
    
    			public void onSuccess(Row[] result) {
    				int iTotalLength = result.length ;
    				
    				ListGridRecord list[] = new ListGridRecord[iTotalLength];
    				for(int i=0; i< iTotalLength; i++){
    					list[i] = new ListGridRecord();
    					list[i].setAttribute("countryName", result[i].getCountryName());
    		        	list[i].setAttribute("countryCode", result[i].getCountryCode());
    		        	list[i].setAttribute("population", result[i].getPopulation());
    				}				
    				response.setData(list);
    				response.setStartRow(iStart);
    				response.setEndRow(iEnd);
    				response.setTotalRows(1000);
    				processResponse(requestId, response);
    			}        	
            });     
               return dsRequest.getData();
            }

    This time I found that return statement of transformRequest executes before processResponse() part written in onSuccess() method for that request. This causes it to give error.

    com.smartgwt.client.core.JsObject$SGWT_WARN: 18:40:42.714:WARN:DataSource:abc:DataSource.processResponse(): Unable to find request corresponding to ID abc$6270, taking no action.

    It means that return statement of transformRequest method should not execute before completion of onSuccess() method. It makes me think to add Timer logic in my code.

    But similar logic is working for other people as I have almost copied this code from 5 files attached with first 2-3 posts of this thread. ( GwtRpcDataSource.java and TestDataSource.java ). In this code there is no any logic of Timer etc. So how does that code works and my doesn't ?

    Also, does this have anything to do with
    Code:
    setClientOnly(true);
    I tried making it as false as given in GwtRpcDataSource.java. But then it gave me error that I dont have Pro version of smartgwt. Is it the case that paging mechanism that I am trying is only available in Pro version and not in LGPL version ?

    Please help.
    Thanks.
    Last edited by vinayakshukre; 28 Apr 2010, 05:48.

    Leave a comment:


  • gcstang
    replied
    Happens when you scroll in a ListGrid

    Originally posted by vinayakshukre
    This thread proved very helpfull to me. But I have one small and stupid question. ( Sorry to post it in this intelligent discussion :-) )

    when is transformRequest method of DataSource is called ? Is it to be called on some onClick event explicitly by developer or is it going to be called by Listgrid on scroll down event of grid ?

    Reading java api doc for this method did not help me.

    Thanks.
    Happens when you scroll in a ListGrid and also when you modify your ListGrid such as removeData, saveAllEdits, redraw and invalidateCache
    Last edited by gcstang; 28 Apr 2010, 04:41.

    Leave a comment:


  • vinayakshukre
    replied
    This thread proved very helpfull to me. But I have one small and stupid question. ( Sorry to post it in this intelligent discussion :-) )

    when is transformRequest method of DataSource is called ? Is it to be called on some onClick event explicitly by developer or is it going to be called by Listgrid on scroll down event of grid ?

    Reading java api doc for this method did not help me.

    Thanks.

    Leave a comment:


  • marbot
    replied
    Hi everyone

    To be able to use the GwtRpcDataSource with every possible Record (and no only GridListRecord) as well as with every possible Data Transfer Object without having to rewrite the whole class every time, I wrote a generic GWT-RPC DataSource, called GenericGwtRpcDataSource<D, R, SA>. It is based on the GwtRpcDataSource of Aleksandras.

    The type-safe abstract class GenericGwtRpcDataSource<D, R, SA>, together with GenericGwtRpcDataSourceService<D> and GenericGwtRpcDataSourceAsync<D>, should greatly simplify your GwtRpcDataSource implementations, so you won't have to care about ClassCastExceptions or to rewrite the whole class every time you need a new DataSource.

    I' ve created a new thread with more info, as this one is a bit overloaded already:

    http://forums.smartclient.com/showthread.php?t=10850

    I thought I should put a pointer in this thread, because maybe this is interesting for some of you.

    cheers
    marbot
    Last edited by marbot; 4 Jun 2010, 12:54.

    Leave a comment:


  • Chazinomaha
    replied
    Originally posted by Chazinomaha
    Hello!

    First off i would like to thank the people that have contributed to this easy to implement method of using the RPC service.

    I copied this stuff and changed all the words etc to make one instance of the servlet work for me. Then I went to do another, and ran into some issues with the second one that are baffling me. As far as I can see, everything about the two different servlet's setup is the same, but for the second one I am getting this error. It also sometimes does not occur, maybe 1/10 attempts to run it.

    Code:
    09:26:38.798 [ERROR] [webreport] Errors in 'generated://378F78684468FC6219051C845A8AEE79/report/client/dbTableTypes/Report_Array_Rank_1_FieldSerializer.java'
    The dbTableTypes package contains the "type"DataSource.java and the "type" definition class. I have made sure and implemented Serializable and generated a SerialVersionUID in both "type".java classes.

    If you need to see more specific information to help me diagnose this problem please just ask. Thanks!
    **EDIT** Nevermind, still have no idea why it works sometimes, and doesn't other times.
    Last edited by Chazinomaha; 13 Apr 2010, 09:42.

    Leave a comment:


  • Chazinomaha
    replied
    mutiple servlets

    Hello!

    First off i would like to thank the people that have contributed to this easy to implement method of using the RPC service.

    I copied this stuff and changed all the words etc to make one instance of the servlet work for me. Then I went to do another, and ran into some issues with the second one that are baffling me. As far as I can see, everything about the two different servlet's setup is the same, but for the second one I am getting this error. It also sometimes does not occur, maybe 1/10 attempts to run it.

    Code:
    09:26:38.798 [ERROR] [webreport] Errors in 'generated://378F78684468FC6219051C845A8AEE79/report/client/dbTableTypes/Report_Array_Rank_1_FieldSerializer.java'
    The dbTableTypes package contains the "type"DataSource.java and the "type" definition class. I have made sure and implemented Serializable and generated a SerialVersionUID in both "type".java classes.

    If you need to see more specific information to help me diagnose this problem please just ask. Thanks!

    Leave a comment:


  • farmer
    replied
    Originally posted by sjivan
    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
    actually, it doesn't work (for me). Looking at the examples here everybody seems to ignore this issue and simply use ListGridRecords?

    Code:
    19:39:44.268 [ERROR] [client] Uncaught exception escaped
    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:90)
        at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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:157)
        at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)

    Leave a comment:


  • weili
    replied
    sorry, i forgot to set field as primary key.
    now it works. thank you

    Leave a comment:


  • weili
    replied
    thany you for the rapid answer
    Originally posted by alius
    It should work if you remove record via remove field or via listGrid.removeData().
    i used listGrid.removeData(). my code as following

    Code:
     DataSource myDS = MyDS.getInstance();
    		
    		final DynamicForm form = new DynamicForm();
    		form.setIsGroup(true);
    		form.setNumCols(4);
    		form.setDataSource(myDS);
    
    		final ListGrid listGrid = new ListGrid();
    		listGrid.setWidth100();
    		listGrid.setHeight(200);
    		listGrid.setDataSource(myDS);
    		listGrid.setAutoFetchData(true);
    		listGrid.addRecordClickHandler(new RecordClickHandler() {
    			public void onRecordClick(RecordClickEvent event) {
    				form.reset();
    				form.editSelectedData(listGrid);
    			}
    		});
    
    		addMember(listGrid);
    		addMember(form);
    
    		IButton button = new IButton("remove selected");
    		button.addClickHandler(new ClickHandler() {
    			public void onClick(ClickEvent event) {
    				ListGridRecord selectedRecord = listGrid.getSelectedRecord();
    				if (selectedRecord != null) {
    					listGrid.removeData(selectedRecord);
    
    				} else {
    					SC.say("Select a record before performing this action");
    				}
    			}
    		});
    		addMember(button);

    Originally posted by alius
    How do you remove record - via dataSource.remove() ?
    If yes then you have to refresh list grid manually.
    i have also attempted to use listGrid.getDataSource().removeData(selectedRecord).
    it failed to remove the record at server side probably because no correct data is passed to executeRemove.

    I can't get data from rec as
    Code:
    JavaScriptObject data = request.getData ();
            final ListGridRecord rec = new ListGridRecord (data);
    another question
    could you tell how to refresh list grid manually?

    Leave a comment:


  • alius
    replied
    Originally posted by weili
    when i delete a selected record, it will be removed at server side, but it stays still in the listgrid.
    does anyone know what's wrong with it? how can i take the record off?
    How do you remove record - via dataSource.remove() ?
    If yes then you have to refresh list grid manually.

    It should work if you remove record via remove field or via listGrid.removeData().

    Leave a comment:


  • weili
    replied
    reflesh listgrid after deleting a row

    i am using listgrid as following
    Code:
     ListGrid aGrid= new ListGrid();
    	  aGrid.setDataSource(gwtRpcDS);
              aGrid.setCanEdit(false);
              aGrid.setAutoFetchData(true);
    gwtRpcDS is a datasource inheriating GwtRpcDataSource with changes as

    Code:
     	@Override
    	protected void executeRemove(final String requestId, DSRequest request,
    			final DSResponse response) {
    		 // Retrieve record which should be removed.
            JavaScriptObject data = request.getData ();
            final ListGridRecord rec = new ListGridRecord (data);
            MyData testRec = new MyData ();
            copyValues (rec, testRec);
      
          // We do not receive removed record from server.
          // Return record from request.
    
           DataCallAsync<MyData> call = GWT.create(DataCall.class);
           call.remove (testRec, new AsyncCallback<Void> () {
                public void onFailure (Throwable caught) {
                	InfoPane.getInstance().setInfo("failure");
                    response.setStatus (RPCResponse.STATUS_FAILURE);
                    processResponse (requestId, response);
                }
                @Override
    			public void onSuccess(Void result) {
                	InfoPane.getInstance().setInfo("success");
                    ListGridRecord[] list = new ListGridRecord[1];
                    // We do not receive removed record from server.
                    // Return record from request.
                    list[0] = rec;
                    response.setData (list);
                    processResponse (requestId, response);
                }
    			
    
            });
    
    
    	}
    when i delete a selected record, it will be removed at server side, but it stays still in the listgrid.
    does anyone know what's wrong with it? how can i take the record off?

    Leave a comment:

Working...
X