Friday 11 November 2022

extraClientlibs Usage

The purpose of property "extraClientlibs" is to selectively load client library for a dialog.

This prevents the unnecessary load of client libs where not required, thus catering to better performance.

This property can directly be set at the dialog with the below syntax:

extraClientlibs - String[] - <specify-specify-the-category-name-of-the-clientlib>

Monday 15 July 2019

Monday 29 April 2019

How to access session in the Sling Model

The session can be easily accessed in the sling model by using the Sling Object annotation. Below code helps us achieve it.

@SlingObject
private ResourceResolver resourceResolver

resourceResolver.adaptTo(Session.class)

Wednesday 17 April 2019

Where are the configurations stored in jcr

The configurations are stored at "/apps/system/config" path in JCR.

cq:Page Vs cq:PageContent

cq:Page is the jcr:primaryType of the page node, whereas
cq:PageContent is the jcr:primaryType for the jcr:content of template node where the information about the page is placed. In case of editable templates the initial content and the structure node's jcr:content is of cq:PageContent type. 

Tuesday 16 April 2019

Query builder | Performance Enhancement | p.guessTotal

In order to boost the performance of query builder, p.guessTotal parameter in the query builder URL can be very useful. This parameter stops the permission check for that session on each node of the result set.

Example::
http://localhost:4502/bin/querybuilder.json?path=/content&1_property=sling:resourceType&1_property.value=foundation/components/text&1_property.operation=like&p.guessTotal=50&orderby=path

Tuesday 12 February 2019

How to load author client libraries only in the edit mode in sightly?

The below code loads the client library only in the preview and edit mode.

<sly data-sly-test="${wcmmode.preview || wcmmode.edit}" data-sly-call="${clientLib.all @ categories='category.name'}"/>

Thursday 7 February 2019

Creating system user | How to create system user in aem cq

System users help us play with the aem reources, make changes and commmit it programmatically. Creating a system user involves couple of steps, the same is illustrated below.

Step 1:: Access crx explorer from the link http://localhost:4502/crx/explorer/index.jsp.

Step 2:: In order to create system user, you should have logged in with the Administrators credentials. Click on login on the crx explorer dashboard.

Step 3:: Click the option called "User Administartion". This now opens up a new window , Click "Create system user" to create one.

Step 4::  Fill the details :: User iD -> system(this is just the user id of the user, can be any name).
Enter the intermediate path: /home/users/system

Step 5:: Select the small green tick to complete the step.

Congratulations!!! You just created a system user.




Monday 10 September 2018

AEM Workflows And Launchers - A powerful tool to automate process.

In this era of automation, the demand is to enforce the process to happen without manual intervention. In order to achieve this workflows and launchers play a major role in achieving it.

Workflows
Workflow allows the developers to automate the steps to be carried out. It allow us to manipulate the jcr resources on the go. AEM provides many inbuilt workflows, but a developer also has the flexibility to create a custom workflow.

The workflow dashboard can be accessed from the below url.
http://localhost:4502/libs/cq/workflow/content/console.html

The state of the workflow can be traced from the Archive tab from the workflow console. Worklow exhibits the following state.

  • Running
  • Completed
  • Suspended
  • Aborted
  • Stale
Launchers
In order to fire the workflows automatically, launcher is the tool that can be of help. The launchers fire the workflow based on the event type, node type, path, etc. For example:: A new property can be set to the page created. In the launcher dialog we have the configuration to select the workflow to associate with it.

Workflow Sessions
The workflow sessions can be very useful to process the payloads. Below code can help the developers fetch the session in a workflow.
session = workflowSession.adaptTo(javax.jcr.Session.class);
session = workflowSession.getSession();
The syntax code snippet to create a custom workflow process is discussed in the below blog.
http://anshumankumaraem.blogspot.com/2017/11/whats-new-in-aem-63.html

What is a payload in workflow ??
This is the resource on which the workflow is subjected. Ex: A Page.
Below code snippet can help fetch the payload in the workflow.
WorkflowData workflowData = workItem.getWorkflowData();
String payLoadPath = (String) workflowData.getPayload();

Thursday 26 April 2018

How to use System user to access the crx repository?

System user is configured in the user mapper configuration in the felix console. In the below example datawrite is the system user.
The below code demonstrates the way in which we can use a system user to access the repository to make changes to it.

Map<String, Object> paramsMap = new HashMap<String, Object>();
paramsMap.put(ResourceResolverFactory.SUBSERVICE, "datawrite");
ResourceResolver resourceResolver = null;
resourceResolver = resourceResolverFactory.getServiceResourceResolver(paramsMap);
Resource res = resourceResolver.getResource("<Path in the repository>");
//Write logic to make changes to the resource.
//Then commit the changes done to the repository.
res.getResourceResolver().commit();

extraClientlibs Usage

The purpose of property "extraClientlibs" is to selectively load client library for a dialog. This prevents the unnecessary load o...