Announcement

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

    selectString is not a function error in RestDataSource transformResponse

    Hi Isomorphic,

    I'm following the documentation for configuring RestDataSource using Spring controllers. I'm getting the error in the title when performing a fetch operation.

    The JSON Response is as follows (shown in Dev console), which pretty much is the same format as in the RestDataSource javadoc:

    Code:
    {"response":{"status":0,"startRow":0,"endRow":1,"totalRows":1,"data":[{"apellido":"last_name","nombre":"name","username":"uname","email":"carlep@live.com.ar","password":""}]}}
    The DataSource definition:

    Code:
    package com.sgrvg.client.main.ds;
    
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.OperationBinding;
    import com.smartgwt.client.data.RestDataSource;
    import com.smartgwt.client.data.fields.DataSourcePasswordField;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    import com.smartgwt.client.types.DSDataFormat;
    import com.smartgwt.client.types.DSOperationType;
    import com.smartgwt.client.types.DSProtocol;
    
    /**
     * @author pabloc
     * 
     * DataSource para administracion de usuarios (modificar datos / password)
     *
     */
    public class UserDS extends RestDataSource {
    	
    	private static UserDS instance = null;
    	
    	public static UserDS getInstance() {
    		if (instance == null) {
    			instance = new UserDS();
    		}
    		return instance;
    	}
    	
    	private UserDS() {
    		super();
    		
    		setClientOnly(Boolean.FALSE);
    		
    //		FIELDS
    		DataSourceTextField username = new DataSourceTextField("username", "Usuario", 50, true);
    		DataSourceTextField nombre = new DataSourceTextField("nombre", "Nombre", 45, true);
    		DataSourceTextField apellido = new DataSourceTextField("apellido", "Apellido", 45, true);
    		DataSourceTextField email = new DataSourceTextField("email", "E-Mail", 255, false);
    //		En cambio de password poner como hidden y luego de la validacion modificarle el valor y hacer el saveData
    		DataSourcePasswordField currentPassword = new DataSourcePasswordField("password", "Password", 50, true);
    
    		setFields(username, nombre, apellido, email, currentPassword);
    		
    //		DSRequest properties
    		DSRequest updateRequest = new DSRequest(DSOperationType.UPDATE);
    		updateRequest.setHttpMethod("PUT");
    		updateRequest.setContentType("application/json");
    		
    //		OPERATION BINDINGS
    		OperationBinding fetch = new OperationBinding(DSOperationType.FETCH, "service/user");
    		fetch.setDataProtocol(DSProtocol.GETPARAMS);
    		fetch.setDataFormat(DSDataFormat.JSON);
    				
    		OperationBinding update = new OperationBinding(DSOperationType.UPDATE, "service/user");
    		update.setDataProtocol(DSProtocol.POSTMESSAGE);
    		update.setDataFormat(DSDataFormat.JSON);
    		update.setRequestProperties(updateRequest);
    		
    		setOperationBindings(fetch, update);
    		
    	}
    }
    The controller:
    Code:
    	@RequestMapping(value="/user", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE )
    	@ResponseBody
    	public DSResponse getUserData(final HttpServletRequest request, Principal principal) {
    		final String currentUser = principal.getName();
    		
    		Usuario usr = usrManager.encontrarUsuarioPorUsername(currentUser);
    		
    		return new DSResponse(usr);
    	}
    The issue happens in the transformResponse method

    In compiled mode, the error happens in ISC_DataBinding.js (line 2721 if it helps)


    Any help would be greatly appreciated.

    Browsers: Any
    GWT Version: 2.5.1
    SmartGWT version: SmartClient Version: v9.1p_2014-03-25/LGPL Development Only (built 2014-03-25)

    #2
    Set dataFormat to JSON on the RestDataSource as a whole. Setting it on just some operationBindings is not enough.

    Comment


      #3
      Excellent, it's working now. Many thanks!

      Comment

      Working...
      X