Expand my Community achievements bar.

SOLVED

Different ways to disable editing a component

Avatar

Level 4

I've got a variety of situations where I have a component A which uses cq:include to include component B. Both A and B are editable and have dialogs. However, when B is included in A, I'd like to disable direct editing of component B, and move the dialog tabs to A. I've seen a couple methods that accomplish this. The first is

<code><% IncludeOptions.getOptions(request, true).forceSameContext(true); %></code>

and the second is

<code><% slingRequest.setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, true); %> <% slingRequest.removeAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE);  %></code>

My understanding is that the first forces the child component into the parent's editing context, and the second just creates no editing context for the child at all. But I'm not sure what the difference really means. As far as I can tell, the only major difference is that the first one only affects the next component include, while the second one affects all includes between the two lines. There's also a minor difference in the markup generated. But beyond that, the dialogs seem to behave the same way. It's possible that my POC is just too simple to see the differences...are there values in a cq:EditConfig node that would be affected? Some other difference?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Both approach will help your need, Earlier method suppress this generated div tag & won't be able to edit the component anymore.  Another one uses filter and is demonstrated at http://www.connectcon.ch/content/dam/cqcon/Pr%C3%A4sentation_Dominik_Suess.pdf

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Both approach will help your need, Earlier method suppress this generated div tag & won't be able to edit the component anymore.  Another one uses filter and is demonstrated at http://www.connectcon.ch/content/dam/cqcon/Pr%C3%A4sentation_Dominik_Suess.pdf