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

jydps87387977
Level 3
Mar 16, 2016 8:56 PM UTC

Any suggestions on this please ?    

Translate
Level 4
Mar 16, 2016 9:17 PM UTC

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/components/foundation/form/checkbox/index.html

See:

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

Translate
jydps87387977
Level 3
Mar 16, 2016 9:55 PM UTC

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 ?

Translate
Lokesh_Shivalingaiah
Level 10
Mar 16, 2016 10:01 PM UTC

Can you post your components content.xml ?

Translate
kautuk_sahni
Level 9
Mar 17, 2016 7:14 AM UTC

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

Translate
Kautuk Sahni
jydps87387977
Level 3
Mar 17, 2016 1:36 PM UTC
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"/>
Translate
edubey
Level 10
Mar 17, 2016 1:43 PM UTC

Check these config properties. It works

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

Translate
jydps87387977
Level 3
Mar 17, 2016 2:05 PM UTC

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 ?

Translate
jydps87387977
Level 3
Mar 20, 2016 8:59 PM UTC

Any suggestions for above ?

Translate
Level 8
Mar 21, 2016 7:49 PM UTC

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

Translate