AEM 6.1 Touch Ui checkbox, how to get it unchecked while reopening the dialog. | Community
Skip to main content
jydps87387977
Level 3
Mar 16, 2016 4:53 PM UTC
Solved

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

[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.
Tyler_Maynard
Tyler_MaynardAccepted solution
Level 4
Jul 28, 2016 8:03 PM UTC

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 11:23 AM UTC

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

Translate
akashs51893872
Level 3
Jan 16, 2019 10:43 AM UTC

This worked for me with Coral component:

Translate
suresh3366
Level 1
Aug 10, 2017 1:12 PM UTC

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

Translate
Level 2
Jun 2, 2017 7:10 AM UTC

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.
Translate
Level 2
Apr 19, 2017 11:47 AM UTC

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. 

Translate
Level 2
Feb 13, 2017 4:04 PM UTC

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

Translate
jeq0214
New Participant
Jul 28, 2016 8:30 PM UTC

This worked for me. Thanks!

Translate
Tyler_Maynard
Tyler_MaynardAccepted solution
Level 4
Jul 28, 2016 8:03 PM UTC

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>


 

Translate
jeq0214
New Participant
Jul 28, 2016 7:47 PM UTC

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?

Translate
Clemente-3SHARE
Level 2
Jul 22, 2016 7:51 PM UTC

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!

Translate