AEM 6.1 Touch Ui checkbox, how to get it unchecked while reopening the dialog. | Community
Skip to main content
jydps87387977
New Participant
March 16, 2016
Solved

AEM 6.1 Touch Ui checkbox, how to get it unchecked while reopening the dialog.

  • March 16, 2016
  • 25 replies
  • 39081 views

[Thread Edited By Adobe]

/*Don’t forget to meet and greet your fellow peers virtually by telling them about yourself here

Go ahead and to it now: https://adobe.ly/3eDnB4v */

 

Actual Post:

Hi,

Using AEM 6.1, Touch Ui dialogs, I have a checkbox (checked by default).

 

1. Checkbox is checked (first time, be default)

2. Uncheck the checkbox and submit the dialog

3. Open the dialog, it is still checked.

Question: Is there any way to uncheck the checkbox in Step 3 above

 

 

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 Tyler_Maynard

After playing around, here is the approach I use now involves using cq:template to prefill the resource with a checked value. Just make sure the name of the value you are saving, and the value that is set when checked are present in the cq:template.

Component:

cq:dialog:

<?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="Checkbox" sling:resourceType="cq/gui/components/authoring/dialog" helpPath="en/cq/current/wcm/default_components.html#Image"> <content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns" margin="{Boolean}false" type="nav"/> <items jcr:primaryType="nt:unstructured"> <column jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <items jcr:primaryType="nt:unstructured"> <hideMobile jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/checkbox" name="./myValue" text="Check By Default" value="isChecked"/> </items> </column> </items> </content> </jcr:root>

 

cq:template

<?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" myValue="isChecked"> </jcr:root>

 

checkbox.html

<h1>${properties.myValue}</h1>


 

25 replies

shreyaj70113487
New Participant
May 2, 2019

Add “uncheckedValue” property. Assign value to it that which should be saved on the node when checkbox is not checked.

Can you please suggest how the same works for classic UI in AEM 6.0

akashs51893872
New Participant
January 16, 2019

This worked for me with Coral component:

suresh3366
New Participant
August 10, 2017

Steps to achieve this

Create nt:unstructured node with sling:resourceType = granite/ui/components/foundation/form/checkbox

Add defaultChecked property (boolean) true

Add “uncheckedValue” property. Assign value to it that which should be saved on the node when checkbox is not checked.

Add “value” property.  The value of this property will be saved on the node when checkbox is selected.

example:

<checkbox

                                                            jcr:primaryType="nt:unstructured"

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

                                                            filedDescription="Select Checkbox"

                                                            name="./checkBox"

                                                            text="Checkbox"

                                                            value="true"

                                                            defaultChecked="{Boolean}true"

                                                            uncheckedValue="false"/>

tried and tested

New Participant
June 2, 2017

This worked for me:

<registerNow
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/checkbox"
    fieldDescription="When checked, the Register Now section button appears on the page for members to use"
    text="Register Now"
    name="./registerNow"
    value="{Boolean}true"/>
<registerNowType
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/hidden"
    name="./registerNow@TypeHint"
    value="Boolean"/>
<registerNowDefaultValue
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/hidden"
    name="./registerNow@DefaultValue"
    value="{Boolean}true" />
  1. When adding a new component, the checkbox is checked.
  2. Unchecking the checkbox in the dialog is saved.
  3. Checkbox remains unchecked when opening the dialog.
New Participant
April 19, 2017

Which AEM version are you using, I am facing this issue in AEM 6.1. Do you have any idea if there is a day care hotfix for the same or has it been fixed in AEM 6.2? Do let me know. 

New Participant
February 13, 2017

I have same kind of issue, so i have added following properties it works as expected.

defaultChecked(boolean) = "true"

unCheckedValue(boolean) = "false".

So now you will be having either true or false in jcr:

Hope it helps!!!!.

jeq0214
New Participant
July 28, 2016

This worked for me. Thanks!

Tyler_Maynard
Tyler_MaynardAccepted solution
New Participant
July 28, 2016

After playing around, here is the approach I use now involves using cq:template to prefill the resource with a checked value. Just make sure the name of the value you are saving, and the value that is set when checked are present in the cq:template.

Component:

cq:dialog:

<?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="Checkbox" sling:resourceType="cq/gui/components/authoring/dialog" helpPath="en/cq/current/wcm/default_components.html#Image"> <content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns" margin="{Boolean}false" type="nav"/> <items jcr:primaryType="nt:unstructured"> <column jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <items jcr:primaryType="nt:unstructured"> <hideMobile jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/checkbox" name="./myValue" text="Check By Default" value="isChecked"/> </items> </column> </items> </content> </jcr:root>

 

cq:template

<?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" myValue="isChecked"> </jcr:root>

 

checkbox.html

<h1>${properties.myValue}</h1>


 

jeq0214
New Participant
July 28, 2016

clemente.pereyra wrote...

In case you are still looking for a solution to this issue, this is what I did and it works as expected.

You need a pair of nodes for each checkbox you want:

<registerNow
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/checkbox"
    fieldDescription="When checked, the Register Now section button appears on the page for members to use"
    text="Register Now"
    name="./registerNow"
    value="true"/>
<registerNowType
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/hidden"
    name="./registerNow@TypeHint"
    value="Boolean"/>

Cheers!

 

I was not able to get a default check. What version are you on?

Clemente-3SHARE
New Participant
July 22, 2016

In case you are still looking for a solution to this issue, this is what I did and it works as expected.

You need a pair of nodes for each checkbox you want:

<registerNow
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/checkbox"
    fieldDescription="When checked, the Register Now section button appears on the page for members to use"
    text="Register Now"
    name="./registerNow"
    value="true"/>
<registerNowType
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/hidden"
    name="./registerNow@TypeHint"
    value="Boolean"/>

Cheers!