AEM 6.2 Touch UI Mutifield check box values stored as string property instead of boolean | Community
Skip to main content
Manjunath_DJ
Level 2
March 14, 2018
Solved

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

  • March 14, 2018
  • 1 reply
  • 2392 views

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

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 smacdonald2008

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);

1 reply

smacdonald2008
smacdonald2008Accepted solution
Level 10
March 14, 2018

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);