WCMMODE Tag deprecation in AEM 6.2 upgrade | Community
Skip to main content
New Participant
Jul 10, 2017 2:15 PM UTC
Solved

WCMMODE Tag deprecation in AEM 6.2 upgrade

Hi,

I tried to use WCMMODE tag in AEM 6.2 and it is not working as expected. we are upgrading from CQ 5.6.1 to AEM 6.2. wcmmode tags are working as expected in cq5.6.1. but here in aem 6.2 it is not working.

<%@ taglib prefix="wcmmode" uri="http://www.adobe.com/consulting/acs-aem-commons/wcmmode" %>

<wcmmode:edit>

This will be output in EDIT mode.

</wcmmode:edit>

Some suggested me to use HTL, Is there anything other than this solution? because at this point of time it was a much more effort for dev and test and also. So I am looking for an alternate approach that anyone can suggest.

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
kautuk_sahni
kautuk_sahniAccepted solution
Employee
Sep 25, 2017 4:19 AM UTC

JAVA:-

    /** @return true if we are in edit mode, otherwise false */

    public final boolean isEditMode() {

        return WCMMode.fromRequest(getRequest()) == WCMMode.EDIT;

    }

JS:-

function CustomWCMMode() {

  this.isPublish = function() {

   return (!ContextHub.Utils.Cookie.exists('wcmmode'));

  }

  this.isEditMode = function() {

   return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'edit');

  }

  this.isPreviewMode = function() {

   return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'preview');

  }

  this.isDesignMode = function() {

   return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'design');

  }

};

var customWcmMode = new CustomWCMMode();

HTL:-

Edit :   ${wcmmode.edit}

This will help you.

~kautuk

Kautuk Sahni

5 replies

kautuk_sahni
kautuk_sahniAccepted solution
Employee
Sep 25, 2017 4:19 AM UTC

JAVA:-

    /** @return true if we are in edit mode, otherwise false */

    public final boolean isEditMode() {

        return WCMMode.fromRequest(getRequest()) == WCMMode.EDIT;

    }

JS:-

function CustomWCMMode() {

  this.isPublish = function() {

   return (!ContextHub.Utils.Cookie.exists('wcmmode'));

  }

  this.isEditMode = function() {

   return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'edit');

  }

  this.isPreviewMode = function() {

   return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'preview');

  }

  this.isDesignMode = function() {

   return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'design');

  }

};

var customWcmMode = new CustomWCMMode();

HTL:-

Edit :   ${wcmmode.edit}

This will help you.

~kautuk

Translate
Kautuk Sahni
Feike_Visser1
Employee
Jul 11, 2017 7:31 AM UTC

In HTL you can do the following:

<sly data-sly-test="${wcmmode.edit}">

This will be output in EDIT mode.

</sly>

No need for taglibs etc anymore.

Translate
Lokesh_Shivalingaiah
Level 10
Jul 10, 2017 8:27 PM UTC

Hi Mahesh,

Instead of acs commons taglibs, use directly this API in  your JSP and get the runmode

com.day.cq.wcm.api.WCMMode

something like this

<%

boolean isEdit = WCMMode.fromRequest(request) == WCMMode.EDIT;

boolean isDesign = WCMMode.fromRequest(request) == WCMMode.DESIGN;

%><c:set var="isEdit" value="<%= isEdit %>" /><c:set var="isDesign" value="<%= isDesign %>" />

Translate
New Participant
Jul 10, 2017 7:27 PM UTC

Thanks for the response smacdonald2008​. But unfortunately at this point of time I can't change the whole code. So I am asking if there is any other way to get this issue resolved, this tags are causing major impact in authoring.

So, I am looking for an alternate approach available if any.

Translate
smacdonald2008
Level 10
Jul 10, 2017 7:23 PM UTC

In AEM 6.2 - HTL is the best practice - JSP and tag libs are not best practice anymore.

Translate