Login Register

ItemFileWriteStore save/setValue Issues

Hello,

I am trying to use the ItemFileWriteStore in order to make modifications as well as additions to the data store and have it update a Tree widget on the page. It is mostly working except for when I go to make a second modification to the data store I get an assertion failure as follows:

assertion failed in ItemFileWriteStore
[Break on this error] undefined

Here are the steps I am taking to get this error:
1. I make a modification to one of the attributes (it's not the id) of an item in the data store using setValue().
2. I call save() on the data store
3. I make another modification to an item in the store using setValue()
4. I get the assertion error above from the following line in the _setValueOrValues function:

this._assert(!this._saveInProgress);

Here's what I noticed when I get the error:
1. The data store is still in a dirty state after the save() method is finished
2. this._saveInProgress was still true even though I saw it get set to false at the end of the save().

Here is my condensed code:

appData._saveEverything =
        function (saveCompleteCallback, saveFailedCallback, newFileContentString) {
                        console.log("In saveEverything");
                        //TODO: Save to database
                        saveCompleteCallback();
        }

function saveApp() {
        var appId = dojo.byId("hdnAppId").value;
        appData.fetchItemByIdentity({identity: appId, onItem: finishUpdate});
}

function finishUpdate(item) {
        appData.setValue(item, "label", dojo.byId("txtTitle").value);
        appData.setValue(item, "href", dojo.byId("txtUrl").value);
        appData.save();
}

Am I missing something? Do I need to do something in the _saveEverything method in the data store or the onComplete method that's passed to save() to fix my problem? Thanks in advance.

IIRC, it's fetchByIdentity, not fetchItemByIdentity.

Maybe that's your problem, not totally sure.

FetchItemByIdentity

FetchItemByIdentity seems to be correct, as I am looking through the API. I am not having trouble retrieving data, but rather updating the fields.

Fix in 1.0

Looks like this was a bug that has been reported and will be fixed in the version 1.0 release.

http://trac.dojotoolkit.org/ticket/4394