@Delete for multifield | Community
Skip to main content
arturl43391132
Level 4
November 15, 2019
Solved

@Delete for multifield

  • November 15, 2019
  • 6 replies
  • 8633 views

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:

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:

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arturl43391132

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.

6 replies

arunpatidar
Community Advisor
Community Advisor
November 16, 2019

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
arturl43391132
Level 4
November 16, 2019

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".

arunpatidar
Community Advisor
Community Advisor
November 16, 2019

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
arturl43391132
arturl43391132AuthorAccepted solution
Level 4
November 26, 2019

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.

arunpatidar
Community Advisor
Community Advisor
November 30, 2019

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
arturl43391132
Level 4
November 30, 2019

Thanks.