【发布时间】:2014-02-28 12:00:42
【问题描述】:
我有以下CQ dialog.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="cq:TabPanel"
activeTab="{Long}0" title="mContactConnect_dialogtitle" headerAsText="true"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1 jcr:primaryType="cq:Widget" anchor="100%" title="myTitle"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<subheadline jcr:primaryType="cq:Widget" fieldLabel="subheadline_label"
name="./subheadline" maxLength="80" xtype="textfield"/>
<text jcr:primaryType="cq:Widget" fieldLabel="text_label" name="./text"
maxLength="150" xtype="textfield"/>
<reference jcr:primaryType="cq:Widget" fieldLabel="reference_label"
name="./reference" forceSelection="true" xtype="pathfield" rootPath ="/content" />
</items>
</tab1>
</items>
</jcr:root>
现在我想引用当前页面上的某些根路径。 为此,我将 PathField 扩展如下:
myExtendedRootPath = CQ.Ext.extend(CQ.Ext.emptyFn, {
init : function(widget) {
var currentPath;
var siteAdmin = CQ.Ext.getCmp("cq-siteadmin");
if (siteAdmin) {
currentPath = siteAdmin.getSelectedPages().shift().id;
} else {CQ.Ext.
currentPath = CQ.utils.WCM.getPagePath();
}
if (currentPath =="page1") {
widget.treeRoot.name = "content/page1";
}
else if (currentPath =="page2") {
widget.treeRoot.name = "content/page2";
}
}
});
CQ.Ext.reg("myExtendedRootPath", myExtendedRootPath.init());
我使用 firebug 跟踪函数调用。为此,我在init : function(widget) { 行上设置了断点。当我向前一步时,steppointer 跳转到最后一行CQ.Ext.reg...
为什么init 函数不调用?
【问题讨论】:
-
不确定这有多大帮助,但您可以将 id 作为 xml 属性添加到路径字段,然后尝试使用 CQ.Ext.getCmp("id value added to the pathfield").setRootPath 访问它("这条路径将是动态路径");将此添加到从 jsp 加载的 js 文件中
-
一开始,您使用的是
dmyExtendedRootPath,之后使用的是myExtendedRootPath——这是一个错字吗?