where does "request" come from in CQ5? - aem

I am new to CQ5.
While I was trying to follow the official guide of how to create a website at
[https://docs.adobe.com/docs/en/cq/5-6-1/howto/website.html], the following code confused me.
Iterator<Page> children = rootPage.listChildren(new PageFilter(request));
I did not find any reference of "request". Can someone tell me where it comes from?
Thanks in advance.

Well request is an instance of the HttpServletRequest that is available implicitly in any JSP file. (Full list here).
Hence you can use them directly without explicitly declaring them.
In AEM (CQ5), apart from the JSP implicit objects, you can get quick access to few AEM, Sling and JCR specific objects by including the global.jsp file in your JSP as shown below.
<%#include file="/libs/foundation/global.jsp"%>
This entire list of objects and tag libraries that would be available through your global.jsp can be found here.

Related

AEM-6.4 Original Value of sling:resourceSuperType for /libs/foundation/components/redirect

I have accidentally make changes to the sling:resourceSuperType value of /libs/foundation/components/redirect in CRXDE. I have tried to google from AEM site like https://www.aemcomponents.dev/ to get the answer, but still no avail.
I would like to know the original value that set to the sling:resourceSuperType. It will be good if someone can share the value here, or will even better if able to share any other site and guide that can get the original properties of each AEM components.
foundation/components/page is the sling:resourceSupertype for /libs/foundation/components/redirect
(The 'redirect' component refers to a page. Hence, its super-type is 'page')
Also you can always copy your jar with a new name and port and extract it. It will create a vanilla system and there you can check it.

Sightly syntax to retrieve crx/de properties in jsp/html page

I would like to retrieve some properties e.g. jcr:created using Sightly or any related syntax for the panel component in AEM adaptive forms. 1
The previous Sighlty syntaxes that I have attempted to retrieve the crx/de properties include:
${properties.jcr:created}
${pageProperties\[jcr:created\].getTime.toString}
${guidePanel.jcr:created}
${resource.jcr:created}]
I have tried the following syntaxes but unable to retrieve the value from the property and in worst cases, the component may not be rendered on screen.
I have looked up on Adobe forum sites and past stackoverflow questions that other people may have asked. I have tried the solutions and given answers but was unable to achieve the result. I would greatly appreciate for any help or sharing of applicable knowledge if you have encountered similar issues or previously attempted to solve similar problems. Thank you!
You can always create Use class in Java or Javascript to access these properties, it's cleaner and testable. Better than that, you can use Sling Models which are more readable and easier to implement, here is a good presentation about it https://www.slideshare.net/accunitysoft/understanding-sling-models-in-aem
Properties of resources are readable without any extra definitions needed.
So you might want to check what resource is handled in your component by adding this:
${resource.path}
Then you can check the returned path in CRXDE if there really is a jcr:created property available at this path - which should be the case if you are accessing a resource that has a proper sling resource type. Then this call should give a valid return value:
${resource.path} ___ created:
${properties.jcr:created.getTime.toString}
If the path is not displayed as well, then it would help if you could post
the repo path of the content resource you are processing
the sling:resourceType
the path to the component's ht(m)l file that you are using

Keycloak templates available variables

I'am googling for a while in order to find a documentation of all available say "variables" I can use in the various Keycloak templates.
by variable I mean all the ${xxx.yyy} things I can use to inject some dynamic values inside the template.
Through the documentation I can find here and there some of them (like ${user.attributes} or ${url.resourcesPath}) but are there others than these ?
Does anyone have a reference link ?
Many Thanks
You can look for the template providers in Keycloak's code.
All the templates are "ftl" files filled with a map called "attributes". Keycloak has a couple of classes which fill those templates with Beans depending on the page or action as CharlyP mentioned. For example:
FreeMarkerEmailTemplateProvider class fills the email templates.
FreeMarkerLoginFormsProvider class fills the login templates.
I did not find any easy to use documentation but I found the Keycloak Javadocs which can be helpful when you look for the *Bean classes of this documentation. These classes seem to be the ones available in most of the templates. And their public methods will match the available properties you can use in the templates.
For example:
You want to know the properties available for the variable url you can check the class UrlBean in the documentation and you will find for example a method getLoginUrl. This means you can access the property url.loginUrl.
That's all I could find for the time being. Hope it will be helpful...

cq:includeClientLib in AEM if included inside a component jsp and the component is present twice on the page

If we give cq:includeClientLib inside my component jsp and if we drag and drop the component twice on that page, will the clientlib gets loaded/included twice?
what will be the case if we do in Sightly way (data-sly-call="${clientlib.all # categories='somecategory'}") ?
And also what is the suggested method of including client libs, either create a clientlib specific to the component and load only for that component or include all the CSS and JS at a common clientlib and use it across?
No, the clientlib is only included once for a category.
This is by design as the HTL (and respective JSP tag) are evaluated during runtime and the processor keeps a map of categories that have already been included and does not include them again.
As #i.net mentioned, each category will only be included once. To answer your follow up question about the suggested method..
The best practice seems to be to define a client library for each component, which is then embedded into a "global" client library. That global client library will then be included within your page template.
/etc/designs/acme/clientlibs-all
categories=["acme-all"]
embed=[compA,compB]
/apps/acme/components/compA/clientlibs
categories=["compA"]
/apps/acme/components/compB/clientlibs
categories=["compB"]
The reason the global client library is located under /etc/designs is to prevent exposing /apps to the public. However, in AEM 6.3, you could make use of the allowProxy property to serve the code at /etc.designs/. This would then look like this:
/apps/acme/clientlibs/clientlibs-all
categories=["acme-all"]
embed=[compA,compB]
allowProxy=true
/apps/acme/components/compA/clientlibs
categories=["compA"]
/apps/acme/components/compB/clientlibs
categories=["compB"]
Adobe recently released a good tutorial of more recent best practices around client library structure: https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part3.html

Sightly - accessing jcr:content values

From a components JavaScript, how do I access values inside jcr:content for the containing page?
I was expecting pageProperties to help but it seems not ... It gives me "title" but other things (custom values for the page, for example) it doesn't work?
Take a look at https://docs.adobe.com/docs/en/cq/5-6-1/developing/sightly/use-api-in-javascript.html
There are various examples on how to read content with JS in CQ 5.6.1.
If it still doesn't work, you might want to post your code snippet so we can better help you find the problem.