Q31.) How do you convert a class to a service ?
You may use Sling Annotations to do so :
import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import org.apache.felix.scr.annotations.Reference; @Component(immediate="true") @Service(interface="SampleService") public class SampleServiceImpl implements SampleService { @Reference private SlingRepository repository; ...
Note: The SCR annotations are deprecated in the latest builds of Apache Felix.
Q32.) Inheritance in CQ at component level ?
Components within AEM are subject to 3 different hierarchies:
- Resource Type Hierarchy:
This is used to extend components using the property sling:resourceSuperType. This enables the component to inherit; for example a text component will inherit various attributes from the standard component.- scripts (resolved by Sling)
- dialogs
- descriptions (including thumbnail images, icons, etc)
- Container Hierarchy :
This is used to populate configuration settings to the child component and is most commonly used in a parsys scenario.
For example, configuration settings for the edit bar buttons, control set layout (editbars, rollover), dialog layout (inline, floating) can be defined on the parent component and propagated to the child components.
Configuration settings (related to edit functionality) in cq:editConfig and cq:childEditConfig are propagated. - Include Hierarchy
This is imposed at runtime by the sequence of includes.
This hierarchy is used by the Designer, which in turn acts as the base for various design aspects of the rendering; including layout information, css information, the available components in a parsys among others.
Q33.) How to add the tab in the Page Properties dialog?
In order to achieve this , you may follow the below steps:
- Copy
/libs/foundation/components/page/dialog
node to your template’s component that you want to add dialog properties to. - Add fields to the dialog
e.g. If you had a page component /apps/<myapp>/components/pages/contentpage
that has sling:resourceSuperType=/libs/foundation/components/page
then you would copy/libs/foundation/components/page/dialog
to /apps/<myapp>/components/pages/contentpage/
to make an overlaid dialog
Q34.) Under page properties, basic tab, what is the use of On time and Off time?
This will trigger automatic replication (to activate or deactivate a page as appropriate) when the ontimes or offtimes defined for a page occur. This is primarily used for Dispatcher Flush agents.
On Time
The date and time at which the published page will be activated. When published this page will be kept dormant until the specified time. Leave these fields empty for pages you want to publish immediately (the normal scenario).
Off Time
The time at which the published page will be deactivated. Again leave these fields empty for pages you want to publish immediately.
Q35.) How to Convert a jar File into an OSGi Bundle?
There is a plugin available in Eclipse to do so. Other methods could also be used.
Convert a Jar into Osgi-jar Other link
Create an OSGI bundle
Q36.) How to render renditions for images dynamically ?
While uploading an asset in CQ5, various renditions are created by default. They can be defined as per need of the project and can be called . Another approach to render the images dynamically would be to use selectors. The complete process is very well explained in the blog below : http://blog.annotateconsulting.com/2013/06/dynamically-generate-image-thumbnails-with-adobe-cq5aem/
Q37.) What happens when a file is Uploaded in CQ5?
http://cq-ops.tumblr.com/post/33794096940/what-happens-when-a-pdf-is-uploaded-into-cq-dam
Q38.) How can we create Custom Tag-Libs for CQ?
This blog defines how to proceed for this http://cq5cms.blogspot.in/2013/02/follow-below-steps-for-creating-custom.html
Q39.) How to upgrade from 5.6 from 5.3/5.4/5.5?
You can check out the documentation for the steps involved in upgrading , as per provided by Adobe. The steps might change depending on the version of the CQ5 http://docs.adobe.com/docs/en/cq/current/deploying/upgrading.html
Q40.) How to create custom xtype multi textfield, pathfield, new window options?
The below blog defines the procedure to do so in detail:
https://helpx.adobe.com/experience-manager/using/creating-aem-multifield-components.html
Q41.) What does adaptTo() method do ?
Sling offers an Adapter pattern to conveniently translate objects that implement the Adaptable interface. This interface provides a generic adaptTo() method that will translate the object to the class type being passed as the argument.
For example to translate a Resource object to the corresponding Node object, you can simply do:
Node node = resource.adaptTo(Node.class);
Q42.) Which one to use JCR API V/s Sling API?
CQ5 as a complex framework is built on top of various other frameworks, on the server-side the most notably ones are JCR (with its implementation Apache Jackrabbit) and Apache Sling. Both are very powerful frameworks, but both of them have some overlap in functionality:
- reading data from the repository (Sling Resources vs JCR nodes/properties)
- notification on repository events (Sling Eventing vs JCR observation)
In these 2 areas you can work with both frameworks, and achieve good results with both. So, the question is, in what situation should you prefer Sling and in what situation pure JCR.
While on pure JCR you only work with raw repository structures (nodes and properties), the Sling resource abstraction offers you easier handling (no need to deal with the repository exceptions any more) and much more options to interact with you business objects and services.
Let me explain via example: let’s assume, that we need to read the title of CQ page
JCR API:
String readTitle (Session session) { Node page = session.getNode("/content/geometrixx/en/services"); Node jcrcontent = page.getChild("jcr:content"); Property titleProp= jcrcontent.getProperty ("title"): String title = titleProp.getValue().getString(); return title; }
Sling API
String readTitle (ResourceResolver resolver) { Resource r = resolver.getResource(/content/geometrixx/en/services"); Page page = r.adaptTo(Page.class); String title = page.getTitle(); return title; }
Problems with JCR API in above example:
- We need to know, that all CQ page properties are stored on the jcr:content node below the page
- the title of the page is encoded in the property “title”.
- Properties are not available immediately as basic types, and need to be converted from Properties to a Value to our expected type (String)
We don’t need to deal with the low-level information (like the jcr:content node) and properties, but we use the appropriate business object (a CQ page object), which is available out of the box and offers a better level of abstraction.
On a Sling resource level we also a bunch of helpers available, which offer some great benefits over the use of plain nodes and properties. (adaptTo(), ValueMap, etc)
Q43.) What is a FileVault?
The FileVault tool (VLT) is a tool developed by Adobe that maps the content of a CRX/CQ instance to your file system. The VLT tool has similar functions as source control system client (such as a Subversion (SVN) client), providing normal check-in, check-out and management operations, as well as configuration options for flexible representation of the project content.
You run the VLT tool from the command line. This document describes how to use the tool, including how to get started and get help, as well as a list of all commands and available options.
Pingback: How to Prepare ? – CQ5 AEM Tricks of Trade
@Hashim, What happens if we configure both On time and Off time same.
Will it deactivate the page or activate.
LikeLike
Hi, I am sure you can try that in your local instance.
LikeLike
I have tried giving same On Time and Off Time in my local instance.Result is nothing happened, even in Replication log no event get triggered.Can you please explain why???
LikeLiked by 1 person
Are you seeing any log entries ? I need to check this once.
LikeLike
Hi ,
A component having design dialog is included in SDI, can i access the design properties in other components of the same page ? Are there any examples for this?
LikeLike
Hi, A design dialog is specific to the design of a particular template. You can access the properties as long as its for a particular template. What role does SDI has in this? Can you please explain the use case in more detail. What are you trying to achieve ?
Thanks
Hashim
LikeLike
Hi Hashim,
What if I want to use OOTB Asset Metadata Report to change its functional logic+UI. What should be the best approach to use it, so that it doesn’t get affected by version upgrade.
LikeLike
Hi,
You should be able to override the Asset Metadata Report in your application code , by creating the same structure and modifying only the necessary files. Any up-gradation would be done on the /libs folder and wont affect your application code. Later you have to customize the application code over-ridden files as per the need.
Please check this link for Best practices : https://docs.adobe.com/docs/en/aem/6-1/develop/platform/overlays.html
LikeLike
Hi Hashim,
I am facing a problem, please help me to resolve it.
1. I have created a page from site admin.
2. Now I go to CRX and rename the name of that node from content folder which belongs to that page.
3. And then after I go to siteadmin and try deleting that page. I am unable to delete that page now.
Please help why it is happening and how can i fix?
Thanks- Rashid
LikeLike
hi, When you go back to step 3, have you refreshed the Siteadmin ? Are you able to see the changes which you made in Step 2 ? I dont understand what are you trying to delete .
LikeLike
Yes, First I refresh teh siteadmin page and find the changes here(change in page name). Now from site admin itself I am try to delete my site page.
I tried same with vanilla instance and found it is working. Thank You!
LikeLike
If its working in Vanilla instance with same steps, then you might have configured something in Siteadmin console. Could you check the JS errors in Console and Errors in Logs to narrow down the issue.
LikeLike
Hi Hashim
What is bundle deployed & not resolved ? Which method from Activator.java class executes ?
Thanks in advance :)
LikeLike
Hi , Could you check the bundle dependencies in system console. Check if all the versions are available to a particular bundle. The check for error logs after restarting the bundle. For second part of question it should be start method : https://github.com/rodo1111/aem-training/blob/master/bundle/src/main/java/cr/prodigious/aem/activator/Activator.java
LikeLike
Hi Hashim – could you plz check the definition part of overlay and extending (Q-30)? I guess definitions are interchanged.
LikeLike
Oh really, can you please direct me to the link you are referring?
LikeLike
If I give cq:include path=”trail” resourceType=”foundation/components/breadcrumb” could you explain what is the function of path here.
Thanks in advance.
LikeLike
Path is name of the node in the page’s jcr:content . That node defines the component breadcrumb
LikeLike