Announcement

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

    Problem with overriding default prompt and timeout settings for a datasource

    Hello,

    We want to be able to override prompt and timeout settings for specific datasources. Here is the code we've been using to do this. This code works and overrides fetchData and removeData no problem. But, it is not overriding addData or updateData. Can you show me what is wrong with it and why it successfully overrides fetchData and removeData but not the other 2?

    Code:
    	var anDS = isc.DataSource.getDataSource("AssetNotes");
    	anDS.addMethods({
    
    	 fetchData : function (record, callback, requestProperties) {
            if (requestProperties == null) requestProperties = {};
            if (requestProperties.timeout == null) requestProperties.timeout = TIMEOUT_LENGTH_SMARTCLIENT_FETCH_SHORT;
            if (requestProperties.prompt == null) requestProperties.prompt = "<spring:message code="prompt.fetch"/>";
            return this.Super("fetchData", [record, callback, requestProperties]);
        },	
    	updateData : function (record, callback, requestProperties) {
            if (requestProperties == null) requestProperties = {};
     
            if (requestProperties.prompt == null) requestProperties.prompt = "<spring:message code="prompt.saving"/>";
            if (requestProperties.timeout == null) requestProperties.timeout = TIMEOUT_LENGTH_SMARTCLIENT_UPDATE_SUPER_LONG;
            return this.Super("updateData", [record, callback, requestProperties]);
        },
        removeData : function (data, callback, requestProperties) {
            if (requestProperties == null) requestProperties = {};
            if (requestProperties.prompt == null) requestProperties.prompt = "<spring:message code="prompt.remove"/>";
            if (requestProperties.timeout == null) requestProperties.timeout = TIMEOUT_LENGTH_SMARTCLIENT_REMOVE;
            return this.Super("removeData", [data, callback, requestProperties]);
        },
        addData : function (record, callback, requestProperties) {
            if (requestProperties == null) requestProperties = {};
            if (requestProperties.prompt == null) requestProperties.prompt = "<spring:message code="prompt.saving"/>";
            if (requestProperties.timeout == null) requestProperties.timeout = TIMEOUT_LENGTH_SMARTCLIENT_ADD_SUPER_LONG;
    
    
            return this.Super("addData", [record, callback, requestProperties]);
        }
    
    })

    #2
    Hmm, this problem seems to happen when calling DynamicForm.saveData() to add or update data. If I make a call to add or update data through a ListGrid, then addData or updateData overrides work fine. So, how I do I get the DynamicForm.saveData() call to honor my overrides as well?

    Comment


      #3
      This is an implementation detail. DynamicForm.saveData() bypasses the DataSource methods you have overridden here and proceeds directly into some deeper logic within the DataSource class.

      There are a few ways you should be able to get the desired effect:
      - use DataSource.transformRequest to set up your explicit properties rather than doing it directly in these action method overrides
      - modify the DynamicForm.saveData method directly
      - modify your app code to either call DataSource.addData(form.getValues(), ...), or to pass a request properties block straight into the normal DynamicForm.saveData method.

      Regards
      Isomorphic Software

      Comment


        #4
        Thanks for the reply. So, will transformRequest logic work consistently across grid and form updates? If so, I'll go that route.

        Comment


          #5
          Yes - this should work. Let us know if it doesn't behave as expected.

          Comment

          Working...
          X