PDA

View Full Version : getValue function is called twice



ramana438
20 Apr 2015, 2:30 AM
While loading the widget on the UI the getValue() method is calling twice. I don't know what is the trigger point of getValue(). I am trying to use this widget on the Dialog of component in Adobe CQ/AEM.
My Custom widget :



/** * @class CQ.CustomPathFieldWidget
* @extends CQ.form.CompositeField
* This is a custom path field with link text and target
* @param {Object} config the config object
*/
/**
* @class Ejst.CustomWidget
* @extends CQ.form.CompositeField
* This is a custom widget based on {@link CQ.form.CompositeField}.
* @constructor
* Creates a new CustomWidget.
* @param {Object} config The config object
*/
CQ.CustomTabWidget = CQ.Ext.extend(CQ.form.CompositeField, {
/**
* @private
* @type CQ.Ext.form.TextField
*/
hiddenField: null,


/**
* @private
* @type CQ.Ext.form.TextField
*/
//linkText: null,


/**
* @private
* @type CQ.Ext.form.TextField
*/
tabName: null,


/**
* @private
* @type CQ.Ext.form.CustomTabImgWidget
*/
customImgWidget: null,


/**
* @private
* @type CQ.Ext.form.FormPanel
*/
formPanel: null,
constructor: function(config) {
config = config || {};
var defaults = {
"border": true,
"labelWidth": 75,
"layout": "form",
//"columns":6
};
config = CQ.Util.applyDefaults(config, defaults);
CQ.CustomTabWidget.superclass.constructor.call(this, config);
},
//overriding CQ.Ext.Component#initComponent
initComponent: function() {
CQ.CustomTabWidget.superclass.initComponent.call(this);
// Hidden field
this.hiddenField = new CQ.Ext.form.Hidden({
name: this.name
});
this.add(this.hiddenField);


this.tabName = new CQ.Ext.form.TextField({
fieldLabel: "Tab Name",
allowBlank: false,
name: './tabname',
listeners: {
change: {
scope: this,
fn: this.updateHidden
}
}
});


this.add(this.tabName);


this.multiField = new CQ.form.MultiField({
fieldLabel: "Tab Content",
name: './tabcontent',
fieldConfig: {
xtype: 'customimgwidget'
},
listeners: {
change: {
scope: this,
fn: this.updateHidden
},
dialogclose: {
scope: this,
fn: this.updateHidden
}
}
});
this.add(this.multiField);
},


processInit: function(path, record) {
this.tabName.processInit(path, record);
this.customImgWidget.processInit(path, record);
},


setValue: function(value) {
var tabdata = JSON.parse(value);
this.tabName.setValue(tabdata.tabname);
console.log(tabdata.tabcontent);
if(tabdata.tabcontent.length != 0) {
console.log("Setting tab content");
this.multiField.setValue(tabdata.tabcontent);
}
this.hiddenField.setValue(value);
},


getValue: function() {
console.log("getValue() function customcompositefield");
return this.getRawValue();
},


getRawValue: function() {
console.log("getRawValue() Composite Field");
var tabdata = {
"tabname" : this.tabName.getValue(),
//"text": this.linkText.getValue(),
//"tabcontent": this.findByType('multifield')[0].getValue(),
"tabcontent": this.multiField.getValue()
};
console.log(tabdata);
return JSON.stringify(tabdata);
}


/*updateHidden: function() {
this.hiddenField.setValue(this.getValue());
this.findParentByType('customimgwidget').callUpdate();
}*/
});
CQ.Ext.reg('custommultifield', CQ.CustomTabWidget);


please let me know if need any further information.

Thanks in advance.

skirtle
20 Apr 2015, 7:14 AM
Put in a breakpoint or use the debugger keyword:


getValue: function() {
debugger;
return this.getRawValue();
},

That'll pause execution and allow you to inspect the stack so you can understand what's going on.

Navn_g45
26 May 2016, 4:00 AM
Hi Ramana,

Did you find the solution for your issue? I am facing the same issue, please let me know how to fix it , if you know.

Thanks,
Naveen