Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

DynamicForm.getValue()

$
0
0
Hi,

As part of our effort to migrate from version 8.2p to version 8.3p, we encountered the following issue ...

The Problem:
---------------

Within our ValuesManager, nested data objects get cleared when ValuesManager's setValues() gets called.

The unexpected field clearing of nested data attributes, occurs right when
this._setMemberValues(this.members[i]) gets called, within the ValuesManager.setValues() method:

Code:

    setValues : function (values) {
        if (isc.isAn.Array(values)) {
            var useFirst = isc.isA.Object(values[0]);
            this.logWarn("values specified as an array." +
                        (useFirst ? " Treating the first item in the array as intended values."
                                  : " Ignoring specified values."));
            if (useFirst) values = values[0];
            else values = null;
        }



        // Duplicate the values object so we can manipulate it and apply it directly to
        // this.values and modify without interfering with external code.
        // _duplicateValues does a recursive duplication based on dataPaths
        var clonedVals = {};
        isc.DynamicForm._duplicateValues(this, values, clonedVals);
        values = clonedVals;

        this.values = values;
        if (this.members) {
            for (var i = 0; i < this.members.length; i++) {
                // setMemberValues will update the members' items to display the values passed in
                // Note that for DynamicForms, it also explicitly calls 'clearValue()' on items
                // for which we have no member - this re-evaluates default values
                this._setMemberValues(this.members[i]);
            }
        }
        // remember values for resetting
        this.rememberValues();

    },

Findings:
----------

We determined that this occurs because one of our custom component's getValue() is not being called as it used
to be in 8.2p. This custom component is a collection holder (listGrid), for which the data is provided from a
nested XML payload.

We narrowed down the following change as potentially being responsible for our getValue() not being called:

DynamicForm.getValue() in 8.2p
Code:

getValue : function (fieldName) {
    // This check for item.getValue() should be unnecessary, since this.values is kept in synch
    // with the values of each form item
        var item = this.getItem(fieldName);
    if (item && isc.isA.Function(item.getValue)) return item.getValue();

    return this._getValue(fieldName);
},

DynamicForm.getValue in 8.3p
Code:

getValue : function (fieldName) {

    var item = this.getItem(fieldName);
    if (item) {
        var fieldName = item.getTrimmedDataPath() || item.name;
    }
    return this._getValue(fieldName);
},

In 8.3p, this._getValue(fieldName) ends up being returned in all situations, whereas in 8.2p,
item.getValue() could be returned instead, if/when applicable.

Was this intended, because it's breaking our logic?

Please advise as to what should be done in regards to this issue.

Thanks,

Viewing all articles
Browse latest Browse all 4756

Trending Articles