Highlighted

AEM 6550 - Sites Dialog Add Boolean Typehints before Submit | AEM Community Blog Seeding

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.6K

Likes

962

Correct Answer

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.6K

Likes

962

Correct Answer

1.1K
kautuk_sahni
Community Manager

14-09-2020

BlogImage.jpg

AEM 6550 - Sites Dialog Add Boolean Typehints before Submit by Sreekanth Choudry Nalabotu

Abstract

Solution
1) Login to CRXDE Lite (http://localhost:4502/crx/de), create folder /apps/eaem-save-checkboxes-as-boolean

2) Create node /apps/eaem-save-checkboxes-as-boolean/clientlib of type cq:ClientLibraryFolder, add String[] property categories with value [cq.authoring.dialog.all], String[] property dependencies with value lodash.


3) Create file (nt:file) /apps/eaem-save-checkboxes-as-boolean/clientlib/js.txt, add

save-checkbox-as-boolean.js

4) Create file (nt:file) /apps/eaem-save-checkboxes-as-boolean/clientlib/save-checkbox-as-boolean.js, add the following code

(function($, $document){
var CHECK_BOX_SEL = "form.cq-dialog input[type='checkbox']";

$document.on("click", ".cq-dialog-submit", convertStringToBoolean);

function convertStringToBoolean(event){
event.stopPropagation();
event.preventDefault();

$(CHECK_BOX_SEL).each(addTypeHint);

$("form.cq-dialog").submit();
}

function addTypeHint(){
var $checkbox = $(this),
value = $checkbox.val(),
$form = $("form.cq-dialog");

if( (value != "true") && (value != "false")){
return;
}

var typeHintName = $checkbox.attr("name") + "@TypeHint";

$form.append($("").attr("name", typeHintName).attr("value", "Boolean"));
}
}(jQuery, jQuery(document)));

Read Full Blog

AEM 6550 - Sites Dialog Add Boolean Typehints before Submit

Q&A

Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager