Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

List list = (List)request.getAttribute("list") only returns a max of 100 items

Avatar

Level 6

I have adapted the   List component to count a number of pages from a list of recipe pagescreated by authors under /content/en/all-recipes

 

I start to count how many pages sit under /content/en/all-recipes as follows

 

    %><cq:include script="init.jsp"/><%
    Integer pageCounter = 0;
    List list = (List)request.getAttribute("list");

    if (!list.isEmpty()) {
        int z = list.size();
        list.size() returned a correct count of the number of recipes I had until I reached a number of recipes > 100. Now I have 170 recipe pages and count is still 100.

 

I tested in CRXDE lite how many pages there is using

SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE(s,'/content/en/all-recipes')

Regards

Clive Stewart

1 Accepted Solution

Avatar

Correct answer by
Level 10
7 Replies

Avatar

Level 10

As far as OOTB List component is concerned, I think It will only return pages which are immediate child pages not all child pages.

Example in geometrixx media:-

Taking /content/geometrixx-media/en as parent path, count of child pages will be 5

Avatar

Level 10

Why not create your own component that uses JCR SQL2/QueryBuilder to query the JCR nodes and return to the front end component. You did use that in CRXDE lite:

SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE(s,'/content/en/all-recipes')

Using these Java APIs will improve your result set. 

Avatar

Level 6

I had thought of that, I have only queried the JCR using SQL 2 from an OSGI bundle which I learn t from the AEM tutorials .

 

I have never tried it directly inside of JSP as I do not know which classes I should use / import to run a SQL 2 query inside of JSP. If there is any documentation or example of how to do this inside a jsp I would greatly appreciate it. If not I will use an OSGI bundle.

Regards

Clive Stewart

Avatar

Correct answer by
Level 10

Here are good documentation link:

Its always recommended to write these code in your java classes rather than in JSP

Avatar

Level 10

I would recommend any time you require a front end component to display nodes/props/ any type of result set - write a custom Java service (using Java APIs - ie JCQ-SQL2 or QuerytBuilder) and use the front end logic for presentation. IMHO - front end is not as good as back end Java APIs for querying JCR data. However - using JS logic - you can make front end component look very good at displaying JCR data. 

Avatar

Level 6

Thank you, I do prefer to use the Java in OSGI, it is also much easier to debug.