Pagination using content fragment list component | Community
Skip to main content
ashishkhadpe
Level 3
May 7, 2020 1:34 PM UTC
Solved

Pagination using content fragment list component

Hi All,

 

Any suggestion on how we can implement the pagination logic using the core content fragment list component.

 

May be extending com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragmentList class but not sure if we can do that.

 

Thanks in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Theo_Pendle
Theo_PendleAccepted solution
Level 8
May 8, 2020 6:07 PM UTC

Hello @ashishkhadpe,

The quick answer is no, you can't extend com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragmentList, for two reasons:

  1. It's an interface (which allows extension, but that yon't help you implement pagination)
  2. The actual implementation, com.adobe.cq.wcm.core.components.internal.models.v1.contentfragment.ContentFragmentListImpl, is not exported in OSGi, so if you extend it and deploy your bundle, you'll get a dependency error.

If you want to "extend" the behavior of the you'll have to use the Delegation Pattern. You can find a tutorial explaining this pattern in AEM here. If you are using Lombok (and I think you should), you can use their @Delegate annotation to reduce on boilerplate code.

However, I assume that you are thinking of pagination as a front-end process (ie: no need to reload the entire page when you go from page 1 to page 2)? In that case, you'll have to implement the pagination logic in JS (using a web component for example, I recommend https://open-wc.org/). Then create a Sling Servletor Model that you can call to get X results at a time. 

Hope this helps! 🙂

1 reply

Theo_Pendle
Theo_PendleAccepted solution
Level 8
May 8, 2020 6:07 PM UTC

Hello @ashishkhadpe,

The quick answer is no, you can't extend com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragmentList, for two reasons:

  1. It's an interface (which allows extension, but that yon't help you implement pagination)
  2. The actual implementation, com.adobe.cq.wcm.core.components.internal.models.v1.contentfragment.ContentFragmentListImpl, is not exported in OSGi, so if you extend it and deploy your bundle, you'll get a dependency error.

If you want to "extend" the behavior of the you'll have to use the Delegation Pattern. You can find a tutorial explaining this pattern in AEM here. If you are using Lombok (and I think you should), you can use their @Delegate annotation to reduce on boilerplate code.

However, I assume that you are thinking of pagination as a front-end process (ie: no need to reload the entire page when you go from page 1 to page 2)? In that case, you'll have to implement the pagination logic in JS (using a web component for example, I recommend https://open-wc.org/). Then create a Sling Servletor Model that you can call to get X results at a time. 

Hope this helps! 🙂

Translate