Announcement

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

    Howto deal with server validation errors while resize/move databound calendar event

    Hi,
    I have got databound timeline with ability to resize/move events. I can not figure out how to handle server validation error (or other error condition) responses. Currently I have got error handler set globally by: RPCManager.setHandleErrorCallback();
    but it seems to be ignored by timeline/calendar and server error response is silently ignored resulting moved event disappearing until refresh.
    I also do not see anything like Listgrid.editFailed() event in Calendar.
    Any advice?
    Thanks,
    MichalG


    #2
    Can you show a standlone sample that demonstrates the problem?

    Comment


      #3
      This is modified SmartClient showcase example: http://www.smartclient.com/#databoundTimeline
      tasks
      Code:
      <DataSource
          ID="tasks"
          serverType="sql"
          tableName="tasks"
          testFileName="/examples/shared/ds/test_data/tasks.data.xml"
      transformResponse="
      if (dsResponse.operationType == 'update') {
        dsResponse.status = -4;
        var errors = { startDate : 'Bla bla' };
        dsResponse.errors = errors;
      }
      return dsResponse;
      "
      >
          <fields>
              <field name="taskId" type="sequence" hidden="true" primaryKey="true" />
              <field name="name"      type="text"     title="Name"    required="true"   />
              <field name="description"      type="text"     title="Description"   />
              <field name="startDate"      type="datetime"     title="Start Date"    required="true"   />
              <field name="endDate"      type="datetime"     title="End Date"    required="true"   />
              <field name="lane"      type="text"     title="Lane"    required="true"   />
              <field name="eventWindowStyle" type="text" />
              <field name="canEdit"      type="boolean"     hidden="true" />
          </fields>
      </DataSource>
      It has transformResponse set to simulate validation error (-4) during any update.
      Try this modified sample online, drag&move starting date of any event and you will see that response error is silently ignored and event disappears.

      Now, if you remove line:
      dsResponse.errors = errors;
      and try it again you will see warning message: "Server returned validation errors: null", but event disappears as well.

      Digging into this I noticed that in Calendar.js you have got processSaveResponse() method:
      Code:
      processSaveResponse : function (dsResponse, data, dsRequest, oldEvent) {
          var newEvent = isc.isAn.Array(data) ? data[0] : data,
              opType = dsRequest ? dsRequest.operationType : null,
              isUpdate = opType == "update",
              isAdd = opType == "add",
              fromDialog = this._fromEventDialog,
              fromEditor = this._fromEventEditor
          ;
      
          delete this._fromEventDialog;
          delete this._fromEventEditor;
      
          if (dsResponse && dsResponse.status < 0) {
              var errors = dsResponse ? dsResponse.errors : null;
              // show any validation errors inline in the appropriate UI
              if (fromDialog) {
                  if (errors) this.eventDialog.items[0].setErrors(errors, true);
                  this.displayEventDialog();
              } else if (fromEditor) {
                  this.eventEditorLayout.show();
                  if (errors) this.eventEditor.setErrors(errors, true);
              }
              // have RPCManager handle other errors
              if (!errors) isc.RPCManager._handleError(dsResponse, dsRequest);
              return;
          }
      [...]
      The line:
      if (!errors) isc.RPCManager._handleError(dsResponse, dsRequest);
      seems to be a problem, because RPCManager._handleError() is never reached in case of validation error response which has errors attribute properly set.
      This is exactly what happens in my app, too.
      Thanks,
      MichalG
      Last edited by michalg; 10 Feb 2017, 04:01.

      Comment


        #4
        You should find this fixed in builds dated February 14 and later - the event that failed the edit will return to where it was before the edit and RPCManager will now show the message from your response.data, as expected in this case.

        Comment


          #5
          So I confirm that the problem has gone in SmartClient Version: v11.0p_2017-02-14/LGPL Development Only (built 2017-02-14).
          Thanks a lot.
          MichalG

          Comment

          Working...
          X