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:
My Component is JSP.
Solved! Go to Solution.
Views
Replies
Total Likes
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
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
In addition to the runmode check suggested by @Vaibhavi_J , 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
@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);
}
%>
Views
Likes
Replies