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
Solved! Go to Solution.
Here are good documentation link:
Its always recommended to write these code in your java classes rather than in JSP
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
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.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Here are good documentation link:
Its always recommended to write these code in your java classes rather than in JSP
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.
Thank you, I do prefer to use the Java in OSGI, it is also much easier to debug.
Views
Replies
Total Likes
Thank you,
Views
Replies
Total Likes