我有一个组件允许用户选择指定路径中的资产。用户选择资产并单击“确定”后,我从资产的属性中获取纬度/经度并将其绘制在谷歌地图上。这工作正常,但现在我希望用户能够选择多个资产,以便可以在地图上放置多个标记。
目前,作者选择资产的对话框如下所示
选择资产并单击“确定”后,我的 java 代码将像这样引用该资产
public class Foo extends WCMUse {
public void activate() {
fileReference = getProperties().get("fileReference", String.class);
....
}
}
问题 有没有办法修改代码,使用户可以选择多个资产,而不仅仅是能够选择一个?我可以访问我的 Java 类中的所有选定资产吗?
我的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"
jcr:primaryType="cq:Dialog"
xtype="dialog">
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Panel"
title="Tab">
<items
jcr:primaryType="cq:WidgetCollection">
<asset-reference
jcr:primaryType="cq:Widget"
fieldLabel="Foo Bar:"
fieldDescription="Select the asset under /content/dam/foo-sync"
name="./fileReference"
xtype="pathfield"
rootPath="/content/dam/foo"/>
</items>
</tab1>
</items>
</items>
</jcr:root>
.context.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"
jcr:primaryType="cq:Component"
jcr:title="My Component"
allowedParents="*/parsys"
componentGroup="My Components"/>
_cq_editConfig.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:EditConfig">
<cq:dropTargets jcr:primaryType="nt:unstructured">
<fileReference
jcr:primaryType="cq:DropTargetConfig"
accept="[text/.*]"
groups="[media]"
propertyName="./fileReference"/>
</cq:dropTargets>
</jcr:root>