Expand my Community achievements bar.

SOLVED

How to map Node properties on the fly to use with List component?

Avatar

Level 3

I'm trying to port custom component to OOTB List component in AEM 5.6.1. Custom component keeps its settings in the node properties which names are different from what com.day.cq.wcm.foundation.List is expecting.

For example: custom component has tag filter implemented and its values stored in the property named "featuredTags", OOTB List component is looking for the property named "tags" (JavaDoc). 

Is there a way how to populate or map such properties on the fly without actually updating repository?

1 Accepted Solution

Avatar

Correct answer by
Level 10
You can extend the list  component and have components app logic to update the JCR to address your needs.  That is, you can perform jcr operations on the fly.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10
You can extend the list  component and have components app logic to update the JCR to address your needs.  That is, you can perform jcr operations on the fly.

Avatar

Level 3

Ok, probably i wasn't explicit in my answer so here are some details:

  • I overlay /lib/foundation/components/list component in /apps/foundation/components/list which is mainly a container with sling:resourceSuperType set to /libs/foundation/components/list and two custom views added
  • I have also another component under /apps/<myapp>/components/publicationList which has sling:resourceSuperType set to foundation/components/list effectively extends /apps/foundation/components/list component
  • under publicationList dir I have init.jsp where I put custom logic list initialization. 

And here comes the problem. Since /apps/<myapp>/components/publicationList already existed before and was completely independent from the OOTB list component it has its own config parameters assigned in multiple instances of that component used in different pieces of content. It didn't use com.day.cq.wcm.foundation.List before and used Xpath query to extract data from repo. What I'd like to do is to leverage OOTB functionality (implying com.day.cq.wcm.foundation.List utilization) for that old component. And the question is how I can "emulate" certain property of the node using value of another property without actually changing the repository? com.day.cq.wcm.foundation.List  takes SlingHttpServletRequest for initialization so whatever I do with the Node (adapted from the current resource) is not presented in the scope used for List initialization. I don't want to actually write into repository during runtime (for performance and security reasons) and wanted to avoid background update of the repo information - system is live and old component is being used by multiple authors.

Any ideas?