我创建了一个自定义小部件。下面给出的是代码片段
this.word = new CQ.Ext.form.TextField({
fieldLabel: "Word",
fieldDescription: "Please enter a word in the format: Word",
allowBlank: false,
autoWidth: false,
// regex: /^[A-Z][a-zA-Z\s]+$/,
// regexText: 'Enter only alphabets here.First character has to be an alphabet in uppercase.',
listeners: {
change: {
scope: this,
fn: this.updateHidden
}
}
});
小部件工作正常。我在功能方面有另外一个与此类似的要求。唯一不同的是fieldLabel和fieldDescription的值。我不认为为此创建另一个小部件是个好主意。有什么方法可以使这两个动态。
仅供参考,我使用的是AEM 6.
提前致谢
答案 0 :(得分:0)
您可以使用侦听器并动态更改值。我用added事件尝试了它,它似乎有效。
this.word = new CQ.Ext.form.TextField({
fieldLabel: "Word",
fieldDescription: "Please enter a word in the format: Word",
allowBlank: false,
autoWidth: false,
// regex: /^[A-Z][a-zA-Z\s]+$/,
// regexText: 'Enter only alphabets here.First character has to be an alphabet in uppercase.',
listeners: {
change: {
scope: this,
fn: this.updateHidden
},
added: function(textfield,ownerct,index){
if(//some condition here){
textfield.fieldLabel = "new field label",
textfield.fieldDescription = "new field description"
}
}
}
});
答案 1 :(得分:0)
如果您想为不同的组件使用相同的小部件,并且每个组件必须是唯一的字段(对于您 - fieldLabel和fieldDescription),
试试这个:
var label = this.fieldLabel;
var description = this.fieldDescription;
this.word = new CQ.Ext.form.TextField({
fieldLabel: (label || label == '') ? label : "Word",
fieldDescription: (description || description == '') ? description : "Please enter a word in the format: Word",
allowBlank: false,
autoWidth: false,
// regex: /^[A-Z][a-zA-Z\s]+$/,
// regexText: 'Enter only alphabets here.First character has to be an alphabet in uppercase.',
listeners: {
change: {
scope: this,
fn: this.updateHidden
}
}
});
" this.fieldLabel" - 获得新的价值' fieldLabel'在使用widget的组件对话框中:
...
fieldLabel="New Value fieldLabel For Custom Widget"
xtype="yourCustomWidget"/>
...