Announcement

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

    JavaScript error on save in List Grid

    SNAPSHOT_v8.3d_2012-09-25/PowerEdition Deployment (built 2012-09-25)

    IE 9.0.8112.16421 on Vista in dev mode.

    When I attempt a save on a ListGrid, it throws a JavaScript error. This happens only when I have a field with a server-side validator attached to it. When I take out the server-side validator, it works fine. In fact, the server-side validator never gets called because of the JS error.

    From the Developer Console, this is the JS error:

    17:31:04.206:MDN7:WARN:Log:Error:
    'Object doesn't support property or method 'getDataPath''
    in http://host:port/portal/portal/sc/modules/ISC_Core.js
    at line 4302

    and in the Eclipse "Dev Mode" console, I get pretty much the same JS error:

    17:31:04.211 [ERROR] [portal] 17:31:04.206:MDN7:WARN:Log:Error: 'Object doesn't support property or method 'getDataPath'' in http://host:port/portal/portal/sc/modules/ISC_Core.js at line 4302
    com.smartgwt.client.core.JsObject$SGWT_WARN: 17:31:04.206:MDN7:WARN:Log:Error: 'Object doesn't support property or method 'getDataPath'' in http://harish-dev:8085/portal/portal/sc/modules/ISC_Core.js at line 4302
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    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.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(Thread.java:662)

    There are no server-side errors.

    To reproduce the error, run the sample, then click on the edit button. Modify the "description" field in the grid, then click save. This should bring up a Javascript error.

    Note that if you only modify the "Note" field, it works fine since there is no server-side validator attached to the "note" field.

    Code:
    	/**
    	 * This is the entry point method.
    	 */
    	public void onModuleLoad() {
    		
    		KeyIdentifier debugKey = new KeyIdentifier();
    		debugKey.setCtrlKey(true);
    		debugKey.setKeyName("D");
    
    		Page.registerKey(debugKey, new KeyCallback() {
    			public void execute(String keyName) {
    				SC.showConsole();
    			}
    		});
    		
    		VLayout layout = new VLayout();
    		
        final ListGrid g = new ListGrid();  
        g.setWidth(550);  
        g.setHeight(224);  
        g.setShowAllRecords(true);  
        g.setCellHeight(22);  
        g.setDataSource(DataSource.get("testCase"));  
    
        g.setAutoFetchData(true);  
        g.setCanEdit(true);  
        g.setEditEvent(ListGridEditEvent.NONE); 
    		g.setRowEndEditAction(RowEndEditAction.SAME);
      
        g.setAutoSaveEdits(false);
            
        IButton editBtn = new IButton("Edit");
        
        editBtn.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				g.startEditing();
    			}
    		});
        
        IButton saveBtn = new IButton("Save");
        
        saveBtn.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				g.endEditing();
    				g.saveAllEdits();
    			}
    		});
        
        layout.addMember(editBtn);
        layout.addMember(saveBtn);
        layout.addMember(g);
        
        layout.draw();
    		
    	}
    This is the server-side Data Source.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <DataSource ID="testCase" serverType="generic">
    	<fields>
    		<field name="name" type="text" title="Name" primaryKey="true" canEdit="false">
    		</field>
    		<field name="description" type="text" title="Description">
               <validators>  
                    <validator type="serverCustom">  
                        <serverObject lookupStyle="new" className="mypkg.DummyValidator"/>  
                        <errorMessage>Invalid Description</errorMessage>  
                    </validator>  
                </validators>
    		</field>
    		<field name="note" type="text" title="Note">
    		</field>
    	</fields>
    	<serverObject lookupStyle="new"
    		className="mypkg.TestService" />
    	<operationBindings>
    		<binding operationType="fetch"  serverMethod="testFetch">
    		</binding>
    		<binding operationType="update"  serverMethod="testUpdate">
    		</binding>
    	</operationBindings>
    </DataSource>
    This is the server-side code:

    Code:
    public class TestService {
    	
    	public List testFetch(DSRequest request) {
    		List rows = new ArrayList();
    	
    		Map row = new HashMap();
    		row.put("name", "Test Name");
    		row.put("description", "Test Description");
    		row.put("note", "Test Note");
    		
    		rows.add(row);
    		
    		return rows;
    	}
    	
    	public List testUpdate(DSRequest request) {
    		List rows = new ArrayList();
    	
    		Map row = new HashMap();
    		row.put("name", request.getOldValues().get("name"));
    		if (request.getValues().get("description") != null) {
    			row.put("description", request.getValues().get("description"));
    		} else {
    			row.put("description", request.getOldValues().get("description"));
    		}
    		
    		if (request.getValues().get("note") != null) {
    			row.put("note", request.getValues().get("note"));
    		} else {
    			row.put("note", request.getOldValues().get("note"));
    		}
    	
    		rows.add(row);
    		
    		return rows;
    	}
    
    }
    I have a simple dummy server-side validator which always returns true for now.

    Code:
    public class DummyValidator {
    	
    	public boolean condition(Object value, Validator validator, String fieldName,
    			Map record, DataSource ds) throws Exception {
    		return true;
    	}
    
    }
    P.S.: This error does not occur in SNAPSHOT_v8.3d_2012-08-01/PowerEdition Deployment.

    Thanks,
    --Harish.

    Please let me know if you need any information I might have missed.

    #2
    Thankyou for the clear test case. This was indeed a recent regression, and we have now resolved the issue.

    The fix will be present in nightly builds going forward (dated September 28 or greater)

    Regards
    Isomorphic Software

    Comment


      #3
      That fixed it.

      Thanks,
      --Harish.

      Comment

      Working...
      X