Expand my Community achievements bar.

SOLVED

@Delete for multifield

Avatar

Level 4

Hello, AEM Community

Could you help please?

I added multifield to my dialog:

<overrideParentalRatingDisplay
   jcr:primaryType="nt:unstructured"
   sling:resourceType="orion2/components/ui/components/foundation/form/multifield"
   composite="{Boolean}true">
  <field
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/container"
   name="./settings/overrideParentalRatingDisplay">
  <items jcr:primaryType="nt:unstructured">
  <key
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/numberfield"
   name="./key"/>
  <value
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/textfield"
   name="./value"/>
  </items>
  </field>
  <granite:data
   jcr:primaryType="nt:unstructured"
   cq-msm-lockable="settings/overrideParentalRatingDisplay"/>
</overrideParentalRatingDisplay>

In crx result looks like this:

1854526_pastedImage_2.png

I want multifield node to be deleted if e.g. item0, item1 will be deleted. I added:

<overrideParentalRatingDisplay-Delete
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/hidden"
   value="{Boolean}true"
   name="./settings/overrideParentalRatingDisplay@Delete"/>

But it doesn't work. Empty node stayed:

1855775_pastedImage_23.png

Do I do something wrong or some different solution exist?

I created multifield component - orion2/components/ui/components/foundation/form/multifield, because multifield situated in libs doesn't support composite multifields.

AEM 6.3

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi, Arun Patidar

Thanks for your answer.

It was not deleted because overrideParentalRatingDisplay has two more things:

<multifieldProperty
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/hidden"
   name="./settings/overrideParentalRatingDisplay/multifieldProperty"
   value="overrideParentalRatingDisplay"/>
<multifieldProperty-converterType
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/hidden"
   name="./settings/overrideParentalRatingDisplay/multifieldProperty-converterType"
   value="MULTIFIELD_PROPERTY"/>

So, if node doesn't have child nodes, it isn't deleted because of these properties. I need these properties for our backend functionality. I decided to leave them and not to delete empty node (it isn't critical).

But if you have an idea how to delete empty node with these properties, it'll be great.

Thanks.

View solution in original post

6 Replies

Avatar

Community Advisor

Hi,

Multifield does support composite. Seems you are using Coral2 resourceType, you should be using Coral3(Granite) type

granite/ui/components/coral/foundation/form/multifield

Multifield — Granite UI 1.0 documentation



Arun Patidar

Avatar

Level 4

Hi, Arun Patidar
Thanks for your answer.

I really don't know why it is so. But our envs have "granite/ui/components/coral/foundation/form/multifield" , where there isn't implementation for "composite". That's why I put implementation with composite and it has superType "granite/ui/components/coral/foundation/form/multifield".

Avatar

Community Advisor

Hi,

I checked in 6.3 and the implementation of the composite is available there.

Did you updated files directly in libs, i.e.  /libs/granite/ui/components/coral/foundation/form/multifield/render.jsp

the parent node is also deleted if you delete all the mutifield items.



Arun Patidar

Avatar

Correct answer by
Level 4

Hi, Arun Patidar

Thanks for your answer.

It was not deleted because overrideParentalRatingDisplay has two more things:

<multifieldProperty
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/hidden"
   name="./settings/overrideParentalRatingDisplay/multifieldProperty"
   value="overrideParentalRatingDisplay"/>
<multifieldProperty-converterType
   jcr:primaryType="nt:unstructured"
   sling:resourceType="granite/ui/components/foundation/form/hidden"
   name="./settings/overrideParentalRatingDisplay/multifieldProperty-converterType"
   value="MULTIFIELD_PROPERTY"/>

So, if node doesn't have child nodes, it isn't deleted because of these properties. I need these properties for our backend functionality. I decided to leave them and not to delete empty node (it isn't critical).

But if you have an idea how to delete empty node with these properties, it'll be great.

Thanks.

Avatar

Community Advisor

you can write a Listener on child node delete event and check parent node has no children then delete parent node as well.

Apache Sling 9 API

or write a sling scheduler to check an empty node and clear periodically.



Arun Patidar