How to Check Touch UI Mode in Sightly HTML

How to get different modes in sightly HTML


<sly data-sly-use.wcmModes="/libs/wcm/foundation/components/page/initwcm.js"></sly>

Classic Edit Mode :

<div data-sly-test="${wcmModes.wcmmode.edit}"> Classic Edit Mode </div>

Touch Edit Mode : 

<div data-sly-test="${wcmModes.isTouchAuthoring}"> Touch Edit Mode </div>

Design Mode :

<div data-sly-test="${wcmModes.wcmmode.design}"> Design Mode  </div>

Disabled mode:


<div data-sly-test="${wcmModes.wcmmode.disabled}"> Disabled mode </div>

AEM/CQ5 EXTJS WIDGETS VS MATCHING GRANITE UI COMPONENTS

EXTJS WIDGETS VS MATCHING GRANITE UI COMPONENTS



ExtJS xtype Granite UI resource type
button granite/ui/components/foundation/form/button
checkbox granite/ui/components/foundation/form/checkbox
componentstyles cq/gui/components/authoring/dialog/componentstyles
cqinclude granite/ui/components/foundation/include
datetime granite/ui/components/foundation/form/datepicker
dialogfieldset granite/ui/components/foundation/form/fieldset
hidden granite/ui/components/foundation/form/hidden
html5smartfile, html5smartimage   granite/ui/components/foundation/form/fileupload
multifield granite/ui/components/foundation/form/multifield
numberfield granite/ui/components/foundation/form/numberfield
pathfield, paragraphreference granite/ui/components/foundation/form/pathbrowser
selection granite/ui/components/foundation/form/select
sizefield cq/gui/components/authoring/dialog/sizefield
tags granite/ui/components/foundation/form/autocomplete

cq/gui/components/common/datasources/tags
textarea granite/ui/components/foundation/form/textarea
textfield granite/ui/components/foundation/form/textfield


Node type Granite UI resource type
cq:WidgetCollection granite/ui/components/foundation/container
cq:TabPanel granite/ui/components/foundation/container

granite/ui/components/foundation/layouts/tabs
cq:panel granite/ui/components/foundation/container


Click here for Adobe Document



How to Create/Delete CQ5/AEM page through Javascript

How to Create/Delete CQ page through Java Script

we can create / delete the CQ page by using OOTB service /bin/wcmcommand by passing necessary parameters.


1) Create : To create page do POST Ajax call to /bin/wcmcommand with below parameters object

  var data = {};
var title = Title of Page //required
var label = name of the page //optional
data['cmd'] = "createPage";
data['title'] = title;
data['_charset_'] = "utf-8";
data[':status'] = "browser";
data['template'] = template path // like -- /apps/geometrixx/templates/homepage
data['parentPath'] = parent page path // like --  /content/geometrixx/en

  $.ajax({
type : "POST",
url : '/bin/wcmcommand',
data:data,
}).done(function(data) {console.log(data);});



2) Delete : To delete page do POST Ajax call to /bin/wcmcommand with below parameters object
              
   var data = {};
data['cmd'] = "deletePage";
data['_charset_'] = "utf-8";
data['force'] = false;
  data['path'] = page apth;// like -- /content/geometrixx/en/test

   $.ajax({
type : "POST",
url : '/bin/wcmcommand',
data:data
     }).done(function(data) {console.log(data);});

How to Create/Delete CQ5/AEM page through Javascript

How to Create/Delete CQ page through Java Script

we can create / delete the CQ page by using OOTB service /bin/wcmcommand by passing necessary parameters.


1) Create : To create page do POST Ajax call to /bin/wcmcommand with below parameters object

  var data = {};
var title = Title of Page //required
var label = name of the page //optional
data['cmd'] = "createPage";
data['title'] = title;
data['_charset_'] = "utf-8";
data[':status'] = "browser";
data['template'] = template path // like -- /apps/geometrixx/templates/homepage
data['parentPath'] = parent page path // like --  /content/geometrixx/en

  $.ajax({
type : "POST",
url : '/bin/wcmcommand',
data:data,
}).done(function(data) {console.log(data);});



2) Delete : To delete page do POST Ajax call to /bin/wcmcommand with below parameters object
              
   var data = {};
data['cmd'] = "deletePage";
data['_charset_'] = "utf-8";
data['force'] = false;
  data['path'] = page apth;// like -- /content/geometrixx/en/test

   $.ajax({
type : "POST",
url : '/bin/wcmcommand',
data:data
     }).done(function(data) {console.log(data);});

How to Create/Delete CQ5/AEM page through Javascript

How to Create/Delete CQ page through Java Script

we can create / delete the CQ page by using OOTB service /bin/wcmcommand by passing necessary parameters.


1) Create : To create page do POST Ajax call to /bin/wcmcommand with below parameters object

  var data = {};
var title = Title of Page //required
var label = name of the page //optional
data['cmd'] = "createPage";
data['title'] = title;
data['_charset_'] = "utf-8";
data[':status'] = "browser";
data['template'] = template path // like -- /apps/geometrixx/templates/homepage
data['parentPath'] = parent page path // like --  /content/geometrixx/en

  $.ajax({
type : "POST",
url : '/bin/wcmcommand',
data:data,
}).done(function(data) {console.log(data);});



2) Delete : To delete page do POST Ajax call to /bin/wcmcommand with below parameters object
              
   var data = {};
data['cmd'] = "deletePage";
data['_charset_'] = "utf-8";
data['force'] = false;
  data['path'] = page apth;// like -- /content/geometrixx/en/test

   $.ajax({
type : "POST",
url : '/bin/wcmcommand',
data:data
     }).done(function(data) {console.log(data);});

AEM CSRF Issue / Forbidden POST Call in AEM

AEM CSRF Issue / Forbidden POST Call in AEM

AEM providing CSRF Protection from 6.0 version on wards. if you are using granite.jquery dependency it will automatically provide CSRF protection framework.

if you are not using cq provided jQuery you must add granite.csrf.standalone as dependency.


if you don't want use above client libs as dependency. you can pass 'CSRF-Token' as header property for async XHR request. Call to '/libs/granite/csrf/token.json' will give 'CSRF-Token' value.



Adobe Document 

CQ5/AEM Issue while reading multifield values using Node API

How to read multifield  using Node API

if you configure one item it will set String type to content node.

if you configure more than one items it will set as Sting[] type to component.

Below snippet code works for both String and String[] types
 
if(currentNode.hasProperty("multifieldProp")){
Value[] options = (currentNode.getProperty("multifieldProp").isMultiple()) ? currentNode.getProperty("multifieldProp").getValues() : null;
if (options == null) {//has single value
Value[] option = {currentNode.getProperty( "optionsConfig" ).getValue()};
options = option;
} 
if ( options != null ) {
for(Value option : options){
System.out.println(option);
}
}
}



How to Obtaining AEM Page Information in JSON Format

AEM / CQ Page Information in JSON Format


you can get page inform by hitting bellow service by passing page path as parameter

http://server:port/libs/wcm/core/content/pageinfo.json?path=<page-path>

Ex : http://localhost:4502/libs/wcm/core/content/pageinfo.json?path=/content/geometrixx/en






AEM/Adobe CQ : Dialog Editor For Classic UI

Dialog Editor

The dialog editor provides a graphical interface for easily creating and editing dialog boxes and scaffolds. To see how it works, double click on the component's dialog.

In Dilaog Editor you can build you dialog with some cq provided widgets like textfield , pathfield etc...

You may face the following issue

1)  Unable to see dialog after double click on it when any custom widget configured 

For this we have to do overlay html.jsp .

Copy html.jsp form /libs/foundation/components/primary/cq/Dialog/html.jsp to /apps/foundation/components/primary/cq/Dialog/html.jsp

In html.jsp at line number 32  you can see  client libs include to that add your custom widgets client libs 

<cq:includeClientLib categories="cq.widgets,cq.tagging,cq.scaffolding,custom.widgets"/>

2)  Unable to find custom widgets in palette to build dialog

For this you have to  overlay "DialogEditorConstants.js". Copy /libs/cq/ui/widgets/source/widgets/DialogEditorConstants.js to  /apps/cq/ui/widgets/source/widgets/DialogEditorConstants.js. After copy you have to configure your custom widgets / cq widgets.

To Configure follow these steps 

Add your custom/cq provided xtype to CQ.DialogEditor.ALLOWEDCHILDS array 

Eg : Here  I have added dialogfieldset

CQ.DialogEditor.ALLOWEDCHILDS = [ 
            "textfield", 
            "textarea", 
            "numberfield", 
            "selection", 
            "combo", 
            "hidden",
            "richtext",
    "multifield",
    "checkbox",
    "pathfield",
     "dialogfieldset"
];

Add your custom/cq provided xtype configs  to CQ.DialogEditor.MAPPINGS object

add the blow object

dialogfieldset: {
        category:CQ.DialogEditor.CONTAINER,
        text:CQ.I18n.getMessage("Dialogfieldset"),
        insertCfg:{
            "jcr:primaryType":"cq:Widget",
            xtype:"dialogfieldset",
            items:{ "jcr:primaryType":"cq:WidgetCollection" }
        },
allowedChilds: CQ.DialogEditor.ALLOWEDCHILDS,
        propList:{
            title:"Dialogfieldset",
            width:"",
            height:"",
collapsed : false,
collapsible: true,
id : ""
        }
    }


you can add some more properties also if u want. you can see the dialog 'dialogfieldset' under Containers Palette


References 








How to Convert classic UI (based on ExtJS) Dialog Touch-optimized UI (based on Granite UI/CoralUI).

Dialog Conversion Tool

The dialog conversion tool is provided to help you extend existing components that only have a dialog defined for the classic UI (based on ExtJS). The tool uses this original dialog to create a duplicate dialog designed for the touch-optimized UI (based on Granite UI/CoralUI).

The goal of this tool is to automate the upgrade (as far as possible) to increase efficiency and reduce errors.

Click here for more details / Adobe Document