AEM 6.1 Touch Ui checkbox, how to get it unchecked while reopening the dialog. | Adobe Higher Education
Skip to main content
jydps87387977
Level 3
March 16, 2016
Beantwortet

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

  • March 16, 2016
  • 25 Antworten
  • 39086 Ansichten

[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

 

 

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von 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 Antworten

jydps87387977
Level 3
March 21, 2016

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

April 19, 2016

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

Hemant_arora
Level 8
April 19, 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.

Tyler_Maynard
Level 4
June 2, 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.

Clemente-3SHARE
Level 2
July 22, 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.

Clemente-3SHARE
Level 2
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!

jeq0214
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?

Tyler_Maynard
Level 4
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
July 28, 2016

This worked for me. Thanks!

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