Announcement

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

    fetchData on grid vs form (difference in hosted vs compiled mode)

    Hello,

    I've noticed a lot that compiled mode and hosted mode do not do the same thing, which makes development life very hard. Maybe it's not related to SmartGWT, but here's an example of unexpected behavior which maybe Isomorphic knows the answer to.

    When fetching data with an object as criteria, the object is converted into a JavaScript on fetch on a ListGrid, but not when using a DynamicForm.



    Code:
    private class MyObject implements Serializable {
    	//dummy object
    	public MyObject() {
    		
    	}
    	public MyObject(String s) {
    		
    	}
    }
    
    private VLayout getClassExTest() {
    	VLayout result = new VLayout();
    	
    	final Label label = new Label();
    	
    	Criteria criteria1 = new Criteria();
    	MyObject [] array = new MyObject[1];
    	array[0] = new MyObject("I am a java object array");
    criteria1.setAttribute("MyArr", array);
    
    DataSource ds = new DataSource() {
    	@Override
    	protected Object transformRequest(DSRequest request) {
    		Criteria incomingCriteria = request.getCriteria();
    		Object o = incomingCriteria.getAttributeAsObject("MyArr");
    		String className = o.getClass().getName();
    		label.setContents("Incoming classname = " + className);
    		
    		return request.getData();
    	}
    };
    ds.setClientOnly(true);
    
    DynamicForm form = new DynamicForm();
    ListGrid grid = new ListGrid();
    
    //		form.setDataSource(ds);
    //		form.fetchData(criteria1); //Incoming classname = [Ltest.client.CustomItemTest$MyObject; also in compiled mode, good
    
    grid.setDataSource(ds);
    grid.fetchData(criteria1); //Incoming classname = com.google.gwt.core.client.JavaScriptObject$  but says $MyObject; in compiled mode, strange
    	
    	result.addMember(form);
    	result.addMember(grid);
    	result.addMember(label);
    	
    	
    	
    	return result;
    }

    Uncomment the form.fetch lines to see it in action.
    Both work in compiled mode as expected: I want my own class there, not a JavaScriptObject. Where is it coming from?

    Tried it with builds 706 and 730.

    thanks for the help

    #2
    This has something to do with the GWTRpcDataSource, not sure what it is. Use SmartGWT Pro and you don't have to worry about any of the details in the client-server comm layer, you don't have to write redundant DTOs, and you get a ton of other functionality as well.

    Comment

    Working...
    X