Index: umc/widgets/CheckBox.js =================================================================== --- umc/widgets/CheckBox.js (Revision 35029) +++ umc/widgets/CheckBox.js (Arbeitskopie) @@ -65,6 +65,12 @@ _getValueAttr: function() { return this.get('checked'); + }, + + setValid(isValid, message) { + // a checkbox cannot be invalid + // (for now, we should consider implementing it!) + return false; } }); }); Index: umc/widgets/_FormWidgetMixin.js =================================================================== --- umc/widgets/_FormWidgetMixin.js (Revision 35029) +++ umc/widgets/_FormWidgetMixin.js (Arbeitskopie) @@ -116,6 +116,7 @@ this.set('invalidMessage', message); this._maskValidSubsetError = false; } + return true; } }); }); Index: umc/widgets/Form.js =================================================================== --- umc/widgets/Form.js (Revision 35029) +++ umc/widgets/Form.js (Arbeitskopie) @@ -456,8 +456,14 @@ } deferred = deferred.then(lang.hitch(this, function(data) { // fire event - this.onSaved(true); - return data; + if (data && parseInt(data.status, 10) == 201) { + // 201 is ridiculous... + this.onValidationError(data.result); + return data; + } else { + this.onSaved(true); + return data; + } }), lang.hitch(this, function() { // fire event also in error case this.onSaved(false); @@ -487,6 +493,24 @@ return widgets; }, + onValidationError(/*Object*/ data) { + // naive implementation + umc.tools.forIn(data, dojo.hitch(this, function(iwidget, error_msg) { + var worked = false; + try { + worked = this.getWidget(iwidget).setValid(false, error_msg); + } catch(e) { + console.log(iwidget, e); + } + if (!worked) { + umc.dialog.notify(error_msg); + } + })); + onSaved(false, data); + + this.onSaved(false); + }, + onSaved: function(/*Boolean*/ success) { // event stub }, Index: umc/store.js =================================================================== --- umc/store.js (Revision 35029) +++ umc/store.js (Arbeitskopie) @@ -142,8 +142,14 @@ else { return this._genericMultiCmd(type, [param]). then(function(results) { - if (results && results instanceof Array) { - return results[0]; + if (results) + if (results instanceof Array) { + // 200 + return results[0]; + } else { + // validation error in singleCmd (put, add, ...) + return {'status' : 201, 'result' : results['0']['object']}; + } } }); } @@ -156,7 +162,7 @@ } else { // send the UMCP command - return this.umcpCommand(this.storePath + '/' + type, params). + return this.umcpCommand(this.storePath + '/' + type, params, false). then(/*REQUIRE:"dojo/_base/lang"*/ lang.hitch(this, function(data) { // make sure that we get an non-empty array //console.log('# _genericMultiCmd - deferred: data=' + String(data));