Expand my Community achievements bar.

SOLVED

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

Avatar

Level 4

[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

 

 

desktop_exl_promo_600x100_gdrp.png

1 Accepted Solution

Avatar

Correct answer by
Level 4

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>


 

View solution in original post

25 Replies

Avatar

Level 2

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. 

Avatar

Level 2

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.

Avatar

Level 2

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

Avatar

Level 1

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