Expand my Community achievements bar.

SOLVED

DropTarget for Component Embedded in Page (AEM 5.6.1)

Avatar

Level 4

We have an image component, its _cq_editConfig.xml is:

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" cq:disableTargeting="{Boolean}true" jcr:primaryType="cq:EditConfig"> <cq:dropTargets jcr:primaryType="nt:unstructured"> <image jcr:primaryType="cq:DropTargetConfig" accept="[image/.*]" groups="[media]" propertyName="./fileReference"> </image> </cq:dropTargets> </jcr:root>

 

We have a page component ("Blurb") which includes this component as the "featuredImage", as well as a "body" parsys which allows the same component to be used:

<div> <h1>*Featured Image</h1> <cq:include path="featuredImage" resourceType="sitename/components/image"/> </div> <div> <h1>*Body</h1> <cq:include path="body" resourceType="sitename/components/page/blurb/parsys"/> </div>

 

If I place a sitename/components/image component in the parsys, I can drag an image from the content finder onto the component to set it.  The featuredImage, however, will not accept the drag-n-drop from the content finder.  If I open the featureImage's edit dialog, I can drag a content finder image to there.  I am the admin user, there are no permission restrictions.

Is this a WCM bug?  Is our component's editConfig missing something?

 

Thanks,
Dave

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hello,

Not sure, what do you mean by "not accepting, when you drop image from content finder"? does it show some warning message when you drop image or after dropping the image it does not render the image.

If it allows to drop and does not render it, then...

It seems like "cq:dropTargets" has not been configured correctly because i can see missing sling:resourceType missing which should be configured under "image" node.

1. Refer OOTB image component edit config -/libs/foundation/components/image/cq:editConfig/cq:dropTargets

2. make sure the node name should be the same which you are using as cq:include "featuredImage" better to use "image" for consistency else node name should match (where the fileReference parameter is set to same node used as include)

3. Update sling:resourceType in "parameter" node to your custom component "sitename/components/image"

Try this and let me know if it does not work.

 

Thanks,

Pawan

View solution in original post

5 Replies

Avatar

Correct answer by
Level 9

Hello,

Not sure, what do you mean by "not accepting, when you drop image from content finder"? does it show some warning message when you drop image or after dropping the image it does not render the image.

If it allows to drop and does not render it, then...

It seems like "cq:dropTargets" has not been configured correctly because i can see missing sling:resourceType missing which should be configured under "image" node.

1. Refer OOTB image component edit config -/libs/foundation/components/image/cq:editConfig/cq:dropTargets

2. make sure the node name should be the same which you are using as cq:include "featuredImage" better to use "image" for consistency else node name should match (where the fileReference parameter is set to same node used as include)

3. Update sling:resourceType in "parameter" node to your custom component "sitename/components/image"

Try this and let me know if it does not work.

 

Thanks,

Pawan

Avatar

Level 4

Thanks Scott, but that article is not relevant to the question.  We have already created the image component according to those instructions.

Avatar

Level 4

Pawan, thanks for your response.

By "not accepted", I mean that the image cannot be dropped on the component.  WCM shows the not allowed image as you hover over the component that you want to drop the image on.  It looks the same as when you try to drag a component from the Sidekick to a parsys that does not allow that component type.

--

I tried adding the <parameters /> node to the editConfig, but it made no difference.  We actually removed that recently, because it was set to the wrong resourceType and changed the resourceType of the component when an image was dropped on.  We could have corrected it, rather than removing it, but it did not appear to make a difference.

The name of the component's JCR node not matching the name of the component (or name of the tag in the editConfig) does not seem to matter.  We've tried naming the featuredImage "image", but it did not resolve the issue.  Likewise, we can name the image component anything when it is in a parsys, and the drag-n-drop works fine.

--

Again, the problem only exists when the component is outside of a parsys.  The drag-n-drop functions fine for instances of the component inside of a parsys.  I've dug into the foundation/components/parsys.  It seems the relevant section for inclusion of parsys children is parsys.jsp:94, which curiously, uses a sling:include (probably for efficiency).  I've tried using the same code in our Blurb page, but it made no difference, drag-n-drop still does not work for the featuredImage node:

<div> <h1>*Featured Image</h1> <sling:include resource="<%= resource.getChild("featuredImage") %>" /> </div>

I've also performed additional testing, and found that the inline editing of text components does not work outside of the parsys.  When I copied the pageTitle (a text component) into the body parsys, the inline editing worked as expected.

--

So I raise the question again, is this a WCM bug?