How to programmatically enable / disable cq:noDecoration?

Avatar

Avatar
Validate 1
Level 1
karthik4
Level 1

Likes

2 likes

Total Posts

30 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
karthik4
Level 1

Likes

2 likes

Total Posts

30 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
karthik4
Level 1

26-06-2020

Hello All,

I have a problem where the overall page renders HTML elements as expected in the publisher when cq:noDecoration is set to "true" on a given component.

However, when cq:noDecoration is set to "true", I cannot edit and make any changes my component; the dialogue does not show. When I set the value to false, it works again, but I the publisher needs the value cq:noDecoration=true.

Is there a nice way for me to programmatically set cq:noDecoration to true only on "author mode"?

Requirement:

  • only set cq:noDecoration to "true" in author mode.
  • only set cq:noDecoration to "false" that is not author mode. 

My Component is JSP.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 50
MVP
Vaibhavi
MVP

Likes

216 likes

Total Posts

181 posts

Correct reply

61 solutions
Top badges earned
Affirm 50
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Affirm 50
MVP
Vaibhavi
MVP

Likes

216 likes

Total Posts

181 posts

Correct reply

61 solutions
Top badges earned
Affirm 50
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile
Vaibhavi
MVP

26-06-2020

Hi @karthik4 

 

You can do a runmode check to know if the instance is author or publisher. You can set the property accordingly. 

 

There are many ways to do. 

Example:

JSP:

If you need to check runmode in jsp. (But will suggest not to add scriptlet, you can move it to taglib and get the result) 

Please use below code:- <% pageContext.setAttribute("runModes", sling.getService(SlingSettingsService.class).getRunModes().toString()); %>

Slightly:

Pretty simple to do

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-now-publish-mode-ed...

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 4
raghavc
Level 4

Likes

63 likes

Total Posts

61 posts

Correct reply

19 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 50
View profile

Avatar
Validate 1
Level 4
raghavc
Level 4

Likes

63 likes

Total Posts

61 posts

Correct reply

19 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 50
View profile
raghavc
Level 4

26-06-2020

In addition to the runmode check suggested by @Vaibhavi , please use IncludeOptions to enable/disable decoration tags. Please refer to the below link

https://www.codermag.net/2016/02/remove-component-wrapper-divs-in-cqaem.html

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

594 likes

Total Posts

705 posts

Correct reply

208 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

594 likes

Total Posts

705 posts

Correct reply

208 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

26-06-2020

@karthik4 Looks like you want to hide the component div and it can be achieved by using the below piece of code.

 

Add the below code into headlibs.html/similar area.

 

<%
if (WCMMode.fromRequest(request) != WCMMode.EDIT && WCMMode.fromRequest(request) != WCMMode.DESIGN) {
slingRequest.setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, false);
}
%>

Add the below code into footlibs.html/similar area.

<%
if (WCMMode.fromRequest(request) != WCMMode.EDIT && WCMMode.fromRequest(request) != WCMMode.DESIGN) {
slingRequest.removeAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE);
}
%>