我在组件对话框节点中创建了AEM Touch UI multifield
。它有一个select
的子字段。选择控件包含权限列表。这个想法是作者可以选择多个权限,并且用户必须至少具有其中一个权限才能查看该组件,或者如果没有为该组件指定权限,则所有用户都将看到它。下面是对话框选项卡的.content.xml
文件(该选项卡通过granite/ui/components/foundation/include
引用包含在内)。
我可以向多字段添加新权限,更改它们,并通过一个警告删除它们:我无法删除列表中的最后一个权限。出于某种原因,一旦我选择了某些东西,AEM就不允许我有一个空的多场。我已尝试将allowBlank
设置为true,但我认为此属性不适用于Touch UI - 无论哪种方式,它都无法解决问题。
如何允许内容作者删除多字段中的所有项目?
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Portal Filters"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<permissions
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/multifield"
fieldDescription="A user must have at least one of these permissions to view this component"
fieldLabel="Permissions">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
name="./permissions">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="/apps/mportal/datasources/permissions"/>
</field>
</permissions>
<missions
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/multifield"
fieldDescription="A user must have at least one of these missions to view this component"
fieldLabel="Missions">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
name="./missions">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="/apps/mportal/datasources/missions"/>
</field>
</missions>
<mtcs
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/multifield"
fieldDescription="A user must have at least one of these mtcs to view this component"
fieldLabel="MTCs">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
name="./mtcs">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="/apps/mportal/datasources/mtcs"/>
</field>
</mtcs>
<languages
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/multifield"
fieldDescription="A user must have at least one of these languages to view this component"
fieldLabel="Languages">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
name="./languages">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="/apps/mportal/datasources/languages"/>
</field>
</languages>
<startdate
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/datepicker"
fieldLabel="Start Date"
name="./startdate"/>
<enddate
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/datepicker"
fieldLabel="End Date"
name="./enddate"/>
</items>
</jcr:root>
答案 0 :(得分:0)
事实证明,AEM Touch UI多字段组件更新值的方式存在问题。如果删除最后一项,则组件不会向服务器发送任何值(非常类似于未选中的复选框)。如果没有项目,您必须明确告诉AEM您要删除多字段的值。方法如下:
permissions-delete
(对应
我的多字段名为permissions
)sling:resourceType
,String
,granite/ui/components/foundation/form/hidden
name
,String
,./permissions@Delete
(其中./permissions
是permissions/field
节点名称字段的值)value
,Boolean
,true 现在当你删除最后一项时,隐藏字段的值将确保它被删除而不是被忽略。