Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

allowBlank on select in multifield (Touch UI) doesn't work

Avatar

Level 2

Using the Touch UI interface, I have a 'multifield' that contains a series of 'select' fields.  I can select, change, and delete items in this multifield just fine, however, when I try to remove the last remaining 'select' from the multifield and save, the last item is not removed.  I've tried setting the 'allowBlank' property to true, but it still won't let me remove the last item from the multifield.  Any ideas on how I can achieve this?

UPDATE

Here is the contents of my .content.xml file for the cq:dialog node.  The /jcr:root/content/items/section-filters/items/permissions node is the offender.  I'm not sure that 'allowBlank' is a valid property in the Touch UI:

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" 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="nt:unstructured" jcr:title="Edit Portal Component" sling:resourceType="cq/gui/components/authoring/dialog"> <content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/tabs"/> <items jcr:primaryType="nt:unstructured"> <section-properties jcr:primaryType="nt:unstructured" jcr:title="Properties" sling:resourceType="granite/ui/components/foundation/container"> <items jcr:primaryType="nt:unstructured"> <caption jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/textfield" fieldDescription="A caption for the component" fieldLabel="Caption" name="./caption"/> <applet-size jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/textfield" fieldDescription="1-12 or flush" fieldLabel="Applet Size" name="./applet-size"/> </items> </section-properties> <section-filters 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" name="./permissions"> <field jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/select" allowBlank="{Boolean}true" name="./permissions"> <datasource jcr:primaryType="nt:unstructured" sling:resourceType="/apps/mportal/datasources/permissions"/> </field> </permissions> <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> </section-filters> </items> </content> </jcr:root>
1 Accepted Solution

Avatar

Correct answer by
Level 2

It turns out there is an issue with the way AEM Touch UI multifield components update values. If you remove the last item, the component sends no value up to the server (much like an unchecked checkbox). You have to explicitly tell AEM that you want to delete the value of a multifield if there are no items in it. Here's how:

  1. At the same level as your multifield node, create a new node (nt:unstructured); I call it permissions-delete (to correspond with my multifield called permissions)
  2. Add the following properties:
    1. sling:resourceTypeStringgranite/ui/components/foundation/form/hidden
    2. nameString./permissions@Delete (where ./permissions is the value of name field of the permissions/field node)
    3. valueBoolean, true

Now when you remove the last item, the value of the hidden field will ensure that it is deleted and not just ignored.

View solution in original post

12 Replies

Avatar

Level 9

It could be some thing in your code(multifield) widget or dialog.xml that is causing this issue. I may be able to give some hint if you post snippet of your code.

Avatar

Correct answer by
Level 2

It turns out there is an issue with the way AEM Touch UI multifield components update values. If you remove the last item, the component sends no value up to the server (much like an unchecked checkbox). You have to explicitly tell AEM that you want to delete the value of a multifield if there are no items in it. Here's how:

  1. At the same level as your multifield node, create a new node (nt:unstructured); I call it permissions-delete (to correspond with my multifield called permissions)
  2. Add the following properties:
    1. sling:resourceTypeStringgranite/ui/components/foundation/form/hidden
    2. nameString./permissions@Delete (where ./permissions is the value of name field of the permissions/field node)
    3. valueBoolean, true

Now when you remove the last item, the value of the hidden field will ensure that it is deleted and not just ignored.

Avatar

Level 9

Hi Harrison,

Thank you for finding  a workaround to fix this issue. It works, I verified by  modifying changes to your component.

M. Shaji Ahmed

Avatar

Level 2

I updated the question with the contents of .content.xml for the cq:dialog node.

Avatar

Level 9
  1. <permissions
  2. jcr:primaryType="nt:unstructured"
  3. sling:resourceType="granite/ui/components/foundation/form/multifield"
  4. fieldDescription="A user must have at least one of these permissions to view this component"
  5. fieldLabel="Permissions"
  6. name="./permissions">
  7. <field
  8. jcr:primaryType="nt:unstructured"
  9. sling:resourceType="granite/ui/components/foundation/form/select"
  10. allowBlank="{Boolean}true"
  11. name="./permissions">

​You have same names(./permissions) for both the fields permissions and field, can you make the names unique and try again

Avatar

Level 2

I'm afraid that did not fix the problem.  The value persists despite all attempts to the contrary! (Unless, of course, I remove it explicitly through the CRX interface.)

Avatar

Level 9

Can you attach package, also which version of AEM r u using?

Avatar

Level 2

I am running AEM 6.0.  Attached is a "base-component", a "test-component" with a sling:resourceSuperType of "base-component", and a tabs folder that contains a dialog tab used in the base-component.  Try adding items to any of the multi-fields, save, then try to remove, save again and reopen the dialog to see if at least one of the items is still there.

Avatar

Level 9

It seems that your package has some missing files, it doesn't work for me. I got

Caused by: org.apache.sling.scripting.jsp.jasper.JasperException: /apps/mportal/components/base-component/base-component.jsp(1,1) File "/apps/mportal/global.jsp" not found

Please make sure you have all necessary files before you upload.

Avatar

Level 2

Sorry about that.  I've created a new package and loaded it into a fresh instance of AEM; it seems to work fine now.  Once you have this new package loaded, you can find a test page at localhost:4502/editor.html/content/mportal/test.html  Open the edit dialog for any of the components on that page and click the "Portal Filters" tab.  If you edit the first component on the page (the one that says "Hello People! (Flush)"), then you should see that there is a permission selected.  Attempting to remove this and reopen the dialog should demonstrate the problem.  Note: changing a permission, adding a new permission, or even removing a permission that's not the last item in the multifield saves just fine.  The issue only occurs when attempting to remove the last item in the multifield.

I really appreciate you being willing to help me with this.

Avatar

Level 9

Hi Harrison,

I don't think it is the problem with your code.  I tried out of box geometrixx-outdoors tab /apps/geometrixx-outdoors/components/tabctrl component which is also a multifield widget. 

I dragged and dropped on geometrixx-outdoors home page and created tabs, when I remove them I see the same problem as yours.

I cannot remove all of them at once, I need to remove one at a time and save. Last one remains, we cannot get rid of this.

It seems that coral ui events might be having issues in saving the data to node.

I request community members from Adobe test it and file a ticket for fix.

Thanks

Avatar

Level 2

Thank you, I verified this with the Admitted Groups field on page properties in the Geometrixx site, and found the same thing there--apparently a bug in the Touch UI.