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

Avatar

Avatar

jydps87387977

Avatar

jydps87387977

jydps87387977

16-03-2016

[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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Tyler_Maynard

Avatar

Tyler_Maynard

Tyler_Maynard

28-07-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>


 

Answers (24)

Answers (24)

Avatar

Avatar

suresh3366

Avatar

suresh3366

suresh3366

10-08-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

Avatar

Avatar

clemente_perey1

Avatar

clemente_perey1

clemente_perey1

22-07-2016

I suppose you already found the solution for your particular scenario. Just in case, here is what I did for the same scenario. It works as expected.

You have to create a pair of nodes for each Checkbox you want to use:
<myCheckbox
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/checkbox"
    text="Check this"
    name="./myCheckbox"
    value="true"/>
<myCheckboxType
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/hidden"
    name="./myCheckbox@TypeHint"
    value="Boolean"/>

Cheers.

Avatar

Avatar

edubey

Avatar

edubey

edubey

17-03-2016

Check these config properties. It works

Path: /libs/foundation/components/page/cq:dialog/content/items/tabs/items/basic/items/column/items/title/items/hideinnav

Avatar

Avatar

shreyaj70113487

Avatar

shreyaj70113487

shreyaj70113487

02-05-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

Avatar

Avatar

akashs51893872

Avatar

akashs51893872

akashs51893872

16-01-2019

This worked for me with Coral component:

1669335_pastedImage_0.png

Avatar

Avatar

davidm351

Avatar

davidm351

davidm351

02-06-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.

Avatar

Avatar

w0lver_n3

Avatar

w0lver_n3

w0lver_n3

19-04-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. 

Avatar

Avatar

saicharanu23805

Avatar

saicharanu23805

saicharanu23805

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

Avatar

Avatar

jeq0214

Avatar

jeq0214

jeq0214

28-07-2016

This worked for me. Thanks!

Avatar

Avatar

jeq0214

Avatar

jeq0214

jeq0214

28-07-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?

Avatar

Avatar

clemente_perey1

Avatar

clemente_perey1

clemente_perey1

22-07-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!

Avatar

Avatar

Tyler_Maynard

Avatar

Tyler_Maynard

Tyler_Maynard

02-06-2016

I ended up just rewording my dialog so its the opposite. Makes the author experience less desirable.

Changed:

Use default container [x] <-- always checked because I want it to be by default, but 'checked=true' is garbage.

Do not use default container [ ] <-- reworded so now its confusing but at least it saves right.

 

Another option: use cq:template node to set the default value that will make it checked by default.

Avatar

Avatar

Hemant_arora

Avatar

Hemant_arora

Hemant_arora

19-04-2016

delete the node 

<enable-delete jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/hidden" name="./facets-enable@Delete" value="{Boolean}true"/>

 

 

and it will work fine. I faced the same issue.

Avatar

Avatar

Deepthi_Anumula

Avatar

Deepthi_Anumula

Deepthi_Anumula

19-04-2016

HI , I am facing the same issue. Could you solve it?

Avatar

Avatar

jydps87387977

Avatar

jydps87387977

jydps87387977

21-03-2016

On removing "value=true", then on checkbox 'check' and submit will store the "value=on".

Avatar

Avatar

leeasling

Avatar

leeasling

leeasling

21-03-2016

Remove the "value=true".  This sets the value every time.

Avatar

Avatar

jydps87387977

Avatar

jydps87387977

jydps87387977

20-03-2016

Any suggestions for above ?

Avatar

Avatar

jydps87387977

Avatar

jydps87387977

jydps87387977

17-03-2016

Thank you for the response.

My requirement is to have the default checkbox as 'checked',

1. When user opens the dialog, first time he will see the checkbox as 'checked'.

2. User unchecks the dialog, and submit the dialog

3. When user reopens the dialog, the checkbox should be unchecked. 

Question: How to achieve Step 3, if this checkbox is marked as checked=true ?

Avatar

Avatar

jydps87387977

Avatar

jydps87387977

jydps87387977

17-03-2016

Here is the checkbox details from .context.xml <enable jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/checkbox" name="./facets-enable" text="Enable Search Facets" value="true"         checked="{Boolean}true"/>
<enable-delete jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/hidden" name="./facets-enable@Delete" value="{Boolean}true"/>

Avatar

Avatar

bsloki

MVP

Avatar

bsloki

MVP

bsloki
MVP

16-03-2016

Can you post your components content.xml ?

Avatar

Avatar

jydps87387977

Avatar

jydps87387977

jydps87387977

16-03-2016

Thank you for the response.

While using the checkbox, with 
-checked=true, 
-value=true
On submitting the dialog will store the string as 'true' in the JCR.

Now again, if the user opens the dialog and uncheck the checkbox and submit the dialog, what will get stored in the JCR ?

On opening the Dialog again, the checkbox seems always checked.

How can the capability to uncheck the checkbox be provided to the user ?

Avatar

Avatar

stevec2515680

Avatar

stevec2515680

stevec2515680

16-03-2016

In the Touch UI, a checkbox is based on this data type: 

https://docs.adobe.com/docs/en/aem/6-0/develop/ref/granite-ui/api/jcr_root/libs/granite/ui/component...

See:

checked boolean
Indicates if the checkbox is checked. Providing checked property (either true or false) will imply ignoreData to be true.

Avatar

Avatar

jydps87387977

Avatar

jydps87387977

jydps87387977

16-03-2016

Any suggestions on this please ?    

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.8K

Likes

1.0K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.8K

Likes

1.0K

Correct Reply

1.1K
kautuk_sahni
Community Manager

17-03-2016

Hi

I am not sure, if this would help you, but please have a look into this :-

Link:- http://stackoverflow.com/questions/10483546/getting-default-checked-checkbox-in-cq5

// Getting Default Checked/Unchecked in Checkbox in AEM

 

I hope this will work for you.

Thanks and Regards

Kautuk Sahni