Aem 无法使用ItemId获取组件
下面是我用作按钮侦听器的代码Aem 无法使用ItemId获取组件,aem,Aem,下面是我用作按钮侦听器的代码 function(comp, evt , record, path) { var str=document.URL; var test=str.replace("http://localhost:4502",""); var a=test.split("\."); var path=a[0]+"/jcr:content"; var dialog = this.findParentByType('dialog'); p
function(comp, evt , record, path) {
var str=document.URL;
var test=str.replace("http://localhost:4502","");
var a=test.split("\.");
var path=a[0]+"/jcr:content";
var dialog = this.findParentByType('dialog');
panel=comp.findParentByType('panel');
alert("panel :: "+panel);
var feedurl = panel.getComponent("Url");
alert(feedurl);
}
feedurl始终显示未定义的内容。Url是隐藏的小部件的itemId。下面是dialog.xml
<basic
jcr:primaryType="nt:unstructured"
title="Basic"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<rootPath
jcr:primaryType="cq:Widget"
fieldLabel="Target Path"
name="./youtubepolling/rootPath"
root="/content/dam"
xtype="pathfield"/>
<btnpanel
jcr:primaryType="cq:Widget"
border="{Boolean}false"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<connectbutton
jcr:primaryType="cq:Widget"
localName="connectButton"
style="float:right;"
text="Connect to Youtube"
xtype="button">
<listeners
jcr:primaryType="nt:unstructured"
click="function(comp, evt , record, path) { //js code defined above }"/>
</connectbutton>
</items>
</btnpanel>
<feedUrl1
jcr:primaryType="cq:Widget"
ignoreData="true"
itemId="Url"
name="./youtubepolling/feedUrl"
value=""
xtype="hidden"/>
</items>
</basic>
在该层次结构之上,类似于:
对话框
widgetCollections
选项卡面板
widgetCollections
面板(基本)
根据,当没有对象引用时,项目ID
是获取组件引用的另一种方法,与要求唯一Id的CQ.Ext.getCmp()
不同
还可以观察到,当我们使用itemId
时,id没有设置到输入字段,而是使用CQ生成的id。另一方面,使用id
属性将给定的id设置为输入字段
另外,使用comp.findParentByType('panel')代码>返回一个面板数组,从最近的面板开始。由于feedurl在该面板中不存在,因此它将为panel.getComponent(“Url”)返回undefined always代码>
尝试如下所示修改JS,并对feedUrl1
使用id
而不是itemId
function(comp, evt , record, path) {
var str=document.URL;
var test=str.replace("http://localhost:4502","");
var a=test.split("\.");
var path=a[0]+"/jcr:content";
var dialog = comp.findParentByType('dialog');
var feedurl = dialog.findById("Url");
console.log(feedurl);
feedurl.setValue(path);
}
感谢我得到了这个对象,现在我正试图通过以下方式设置该对象的value属性:feedurl.value=path;警报(“提要::”+feedurl.value);“警报”向我显示要设置的值,但在节点内部“未设置”仍然为空。请尝试setValue()
method。请发现我的答案已编辑。已尝试,我在网络选项卡中看到参数正在运行(名称和值),但该小部件的值属性仍然为空。