Announcement

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

    oldValues not set when removing

    Hello, I'm using a databound calendar using a GwtRPCDatasource as backend. When I delete an event, I get only the event identifier in the record that I receive (with request.getData()) but in the server I need more information in order to identify the data that I need to remove. This data is in the rest of the record fields so I try to get it with

    Code:
    request.getAttributeAsJavaScriptObject("oldValues");
    but I'm getting null, while this same code works fine when I'm updating an element. According to the SmartClient documentation, in the DSRequest page, it says for oldValues field:

    "For an update or remove operation, the original values of the record to be updated or removed. oldValues is automatically added to DSRequests submitted by DataBound Components. Available on the server via DSRequest.getOldValues().

    The server can compare the oldValues to the most recent stored values in order to detect that the user was looking at stale values when the user submitted changes (NOTE: this means of detecting concurrent edit is sometimes called "optimistic concurrency" or "long transactions").

    In applications where a policy of "last update wins" is not appropriate when updating certain fields, special UI can be shown for this case. For example, on detecting concurrent edit, the server may send back a special dsResponse.status code that the client application detects, offering the user a choice of proceeding with the operation, discarding edits, or reconciling new and old values in a special interface."


    So, according to the documentation, oldValues is supposed to contain the complete record for the update and remove operation, but it's not the case for remove.

    Is there any other way to access the record that is being removed?

    #2
    I have the same problem:

    With update operation, it works, but with remove operation, dsRequest.oldValues is undefined

    transformRequest : function (dsRequest) {
    if (dsRequest.operationType == "update" || dsRequest.operationType == "remove") {
    return isc.addProperties({}, dsRequest.oldValues, dsRequest.data);
    }
    return isc.addProperties({}, dsRequest.data);
    }


    I found a solution by setting the oldvalues fields manually:

    var rec = keywordTree.getSelectedRecord ();
    var params = {
    foobar:rec.foobar,
    etc..
    };
    return isc.addProperties({}, params, dsRequest.data);

    Comment

    Working...
    X