Thoughts on soft-wa.re

A blog of various opinions and ideas on soft-wa.re development

Demos

Copy And Pasting AEM Components

I am learning AEM, and I am very new to the system. I think this post will illustrate that, and possibly help other newbies.

So the ticket I was working on was to make a header for some of the new landing pages for this site we are building. A similar component already existed but didn’t fill all the use cases, so I figured I could copy and paste the component, so I don’t break the old one with my inexperience, but I have a new one two experiment with.

So I copied and pasted the new page from another page. Surprisingly that worked pretty well. I don’t recall having to make any special changes.

so this was fine.

> cp ui.content/../usa/en/originalpage ui.content/../usa/en/copiedpage

but the trouble I ran into was when I tried to copy-paste an existing component, to work off of.

> cp ui.apps/../components/content/originalcomponent ui.apps/../components/content/copiedcomponent

I searched the code several times looking for references to ‘originalcomponent’, but I had forgotten to search by file name. So I can’t quite explain it, but I seem to recall that AEM looks for files of the same name of the folder first, and that worked for me.

This make me think of the Resource Mapping, and while I think that is related, I don’t think that is exactly what was going on.

So I also needed to run

> mv copiedcomponent/originalcomponent.html copiedcomponent/copiedcomponent.html

So I am pretty sure this also is related to how AEM can handle different file types for the same page. So if you wanted to also define a JSP for a page then you could also

> vim copiedcomponent/copiedcomponent.jsp

and then users could GET two different versions of the same page.

> curl example.com/usa/en/copiedcomponent.jsp
> curl example.com/usa/en/copiedcomponent.html

This might be more useful with something like html/pdf, or json/xml, but I really don’t know, at this point I am hypothesizing.

tags: