在CQ5中,我创建了一个自定义小部件,我已经编写了一个javscript。这个文件在test.SubdomainNewslistingWidget.superclass.constructor.call(this,config);
行上抛出“未捕获的typeError:无法读取未定义的属性超类”var test = {};
test.SubdomainNewslistingWidget = CQ.Ext.extend(CQ.form.CompositeField, {
/**
* @private
* @type CQ.Ext.form.Hidden
*/
hiddenField : null,
headline:null,
date:null,
description:null,
url:null,
checkbox : null,
emptyField:null,
constructor : function(config) {
config = config || {};
var defaults = {
"border" : true
};
config = CQ.Util.applyDefaults(config, defaults);
test.SubdomainNewslistingWidget.superclass.constructor.call(this, config);
},
// overriding CQ.Ext.Component#initComponent
initComponent : function() {
test.SubdomainNewslistingWidget.superclass.initComponent.call(this);
this.hiddenField = new CQ.Ext.form.Hidden({
name : this.name
});
this.add(this.hiddenField);
this.headline = new CQ.Ext.form.TextField({
fieldLabel : "Headline",
labelStyle : 'display:block;width:85px;',
width : 600,
allowBlank : false,
listeners : {
change : {
scope : this,
fn : this.updateHidden
}
}
});
this.add(this.headline);
this.date = new CQ.form.DateTime({
fieldLabel : "Date",
labelStyle : 'display:block;width:85px;',
width : 600,
allowBlank : false,
editable: false,
hideTime: true,
dateFormat: "d F Y",
listeners : {
change : {
scope : this,
fn : this.updateHidden
}
}
});
this.add(this.date);
this.description = new CQ.Ext.form.TextArea({
fieldLabel : "Description",
labelStyle : 'display:block;width:85px;',
width : 600,
allowBlank : false,
listeners : {
change : {
scope : this,
fn : this.updateHidden
}
}
});
this.add(this.description);
this.url = new CQ.form.PathField({
fieldLabel : "URL",
labelStyle : 'display:block;width:85px;',
rootPath : "/content/mercer",
editable : true,
width : 600,
allowBlank : false,
listeners : {
dialogselect : {
scope : this,
fn : this.updateHidden
},
change : {
scope : this,
fn : this.updateHidden
}
}
});
this.add(this.url);
this.checkbox = new CQ.form.Selection({
type:"checkbox",
fieldLabel:"Link Target",
options:displayOptionsAnchorTargetSubdomainNewslisting(),
listeners: {
selectionchanged: {
scope:this,
fn: this.updateHidden
}
},
optionsProvider: this.optionsProvider
});
this.add(this.checkbox);
/**
* Added a dummy Empty field to avoid ArrayIndexOutOfBound Exception in the resultant array
* Without this hidden field, the empty values will be not be added to the multifield list
*/
this.emptyField = new CQ.Ext.form.TextField({
fieldLabel: "Empty Field",
width:200,
maxLength: "30",
defaultValue: "empty",
hidden:true,
value:"empty",
});
this.add(this.emptyField);
},
// overriding CQ.form.CompositeField#setValue
setValue : function(value) {
var parts = value.split(/<#-@>/);
console.log("displayOptionsAnchorTargetSubdomainNewslisting#parts", parts);
this.headline.setValue(parts[0]);
this.date.setValue(parts[1]);
this.description.setValue(parts[2]);
this.url.setValue(parts[3]);
this.checkbox.setValue(parts[4]);
this.emptyField.setValue(parts[5]);
this.hiddenField.setRawValue(value);
},
// overriding CQ.form.CompositeField#getValue
getValue : function() {
return this.getRawValue();
},
// overriding CQ.form.CompositeField#getRawValue
getRawValue : function() {
return this.headline.getValue() + "<#-@>"
+ this.date.getValue() + "<#-@>"
+ this.description.getValue() + "<#-@>"
+ this.url.getValue() + "<#-@>"
+ this.checkbox.getValue() + "<#-@>"
+ this.emptyField.getValue();
},
// private
updateHidden : function() {
this.hiddenField.setValue(this.getValue());
}
});
function displayOptionsAnchorTargetSubdomainNewslisting()
{
return [{
"text":"check to open link in new tab",
"value":true
}]
}
// register xtype
test.SubdomainNewslistingWidget.XTYPE = "subdomainNewslisting";
CQ.Ext.reg(test.SubdomainNewslistingWidget.XTYPE, test.SubdomainNewslistingWidget);
我无法找到问题所在。任何帮助表示赞赏。