Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

AEM 6.2 Touch UI Mutifield check box values stored as string property instead of boolean

Avatar

Level 2

Hi,

AEM Version- AEM 6.2

I have created mutifield Touch UI with checbox's but property of checkbox is stored as string instead of boolean in JCR.

TypeHint is used to convert to required data type it didn't work in mutifield but it works fine in normal dialog.

Below is the dailog.xml for check box used

<test

           jcr:primaryType="nt:unstructured"

          sling:resourceType="granite/ui/components/foundation/form/checkbox"

          name="./test"

          text="Test"

          value="{Boolean}true"/>

<testDelete

           jcr:primaryType="nt:unstructured"

           sling:resourceType="granite/ui/components/foundation/form/hidden"

           name="./test@Delete"

          value="{Boolean}true"/>

<testType

        jcr:primaryType="nt:unstructured"

       sling:resourceType="granite/ui/components/foundation/form/hidden"

       name="./test@TypeHint"

       value="Boolean"/>

Any pointer Please help.smacdonald2008 kautuksahni

1 Accepted Solution

Avatar

Correct answer by
Level 10

This is how it works in AEM 6.2. I noticed that when i was usng Sling Models to read a checkbox. I had to use:

    @Inject @Optional

    public String show;

Where show is the checkbox.

To make it more interesting - in Sling Models - an exception is thrown if the checkbox is unchecked and i tried to set a Bean. I needed to do this:

//If checkbox is unchecked

  if (show == null)

            heroTextBean.setShow("off");

        else

              heroTextBean.setShow(show);

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

This is how it works in AEM 6.2. I noticed that when i was usng Sling Models to read a checkbox. I had to use:

    @Inject @Optional

    public String show;

Where show is the checkbox.

To make it more interesting - in Sling Models - an exception is thrown if the checkbox is unchecked and i tried to set a Bean. I needed to do this:

//If checkbox is unchecked

  if (show == null)

            heroTextBean.setShow("off");

        else

              heroTextBean.setShow(show);