2014-10-30 41 views
1

我在組件對話框節點中創建了AEM Touch UI multifield。它有一個select的子字段。選擇控件包含權限列表。這個想法是,作者可以選擇多個權限,並且用戶必須至少具有其中一個權限才能看到該組件,或者如果沒有爲該組件指定權限,則所有用戶都會看到它。以下是對話框選項卡的.content.xml文件(該選項卡通過granite/ui/components/foundation/include參考包含在內)。在AEM Touch UI多字段中允許空白值(選擇字段)

我可以添加新的權限到多字段,更改它們,並刪除它們與一個警告:我無法刪除列表中的最後一個權限。出於某種原因,一旦我選擇了某件事物,AEM不允許我有一個空的多場。我試着將allowBlank設置爲true,但我認爲這個屬性不適用於Touch用戶界面 - 無論哪種方式,它都不能解決問題。

如何讓內容作者刪除多字段中的所有項目?

<?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

事實證明,AEM Touch UI多字段組件更新值的方式存在問題。如果刪除最後一個項目,組件將不會向服務器發送任何值(就像未選中的複選框一樣)。如果沒有任何項目,您必須明確告訴AEM您想要刪除多字段的值。方法如下:

  1. 在與多字段節點相同的級別上,創建一個新節點 (nt:unstructured);我把它叫做permissions-delete
  2. 添加以下屬性(與我的萬事稱爲permissions對應 ):
    1. sling:resourceTypeStringgranite/ui/components/foundation/form/hidden
    2. nameString./[email protected](其中./permissions是名稱字段的值permissions/field節點)
    3. valueBoolean,真正

現在,當您刪除最後一項時,隱藏字段的值將確保它被刪除,而不是被忽略。

相關問題