Q16.) Any custom components that you have used in your project which not relevant to out of box component ?
This is mostly an experience based question. Be prepared to give a good example of a functionality which you have done (or someone in your project did) and you consider it as the most interesting thing ever.
Personally, I explain triggering a workflow/scheduler by addition of a particular Tag from the dialog of component , which I did in one of my project.
Q17.) How can we inherit properties of one dialog to another dialog?
This is possible if the inherited component has the property name same as the base component.
BASE COMPONENT
- dialog
- text (name: “./text/content”) –xtype=textfield
OTHER COMPONENT
- dialog
- text (inherited from base) –xtype=textfield
- textValue (not inherited from base) –xtype=textfield
However if you wish to inherit a particular Tab of a dialog from the Base component , you may use xtype="cqinclude"
Q18.) Can we create page without template ?
Yes. It’s not a good practice to create a page manually,however its achievable —
- Create a node of type cq:Page and save.
- Add cq:PageContent node under page node.
- Add required properties to show the component & if you want to add some default node under this cq:PageContent node add all of them manually.
Whatever we did manually above is done by Templates in CQ5 via siteadmin console. When we create a page using template via siteadmin then siteadmin uses content page component & it copies all the child nodes under the template to a newly created page node.
Q19.) What is the difference between dialogue & design dialogue?
Dialogs & Design Dialogs are the collection of widgets used to get input from author. these are the key elements of a component as they provides a way of interaction between author and a CQ5 component. It means values inserted via author in these dialog, works as input for a component in CQ5.
Note : “Design dialogs are special kind of dialog those are available only at page design mode”.
Difference between dialog and design dialog?
Criteria | Dialog | Design Dialog |
Definition | Dialog will change the content at the page level. | Design dialog will change the content at the template level. |
Availability | authored in edit mode | authored in design mode |
Naming Convention | cq:Dialog node with name dialog | cq:Dialog node with name design_dialog |
Value Storage | stored under pages jcr:content node | stored under design page located under /etc/design |
Accessing Values in CQ5 JSPs | via properties object | via currentStyle object. |
Q20.) What are the possible bundle state / Lifecycle of an OSGi Bundle?
A bundle has 6 states in its Lifecycle:
- INSTALLED: The OSGi runtime knows the bundle is there.
- RESOLVED: The bundle is there and all it’s prerequisites (dependencies) are available. The bundle can be started (or has been stopped).
- STARTING: The bundle is being started. If it has a BundleActivator class, the BundleActivator.start() method is being executed. When done, the bundle will become ACTIVE. Note: Bundles that can be activated lazily (Bundle-ActivationPolicy: lazy) stay in this state until one of their class files is loaded.
- ACTIVE: The bundle is running.
- STOPPING: The bundle is being stopped. If it has a BundleActivator class, the BundleActivator.stop() method is being executed. When done, the bundle will become RESOLVED.
- UNINSTALLED: The bundle has been removed from the OSGi runtime.
Q21.) What is a Resource resolver ?
The ResourceResolver
defines the service API which may be used to resolve Resource
objects. The resource resolver is available to the request processing servlet through the SlingHttpServletRequest.getResourceResolver()
method. A resource resolver can also be created through the ResourceResolverFactory
.
The ResourceResolver
is also an Adaptable
to get adapters to other types. A JCR based resource resolver might support adapting to the JCR Session used by the resolver to access the JCR Repository.
A ResourceResolver
is generally not thread safe! As a consequence, an application which uses the resolver, its returned resources and/or objects resulting from adapting either the resolver or a resource, must provide proper synchronization to ensure no more than one thread concurrently operates against a single resolver, resource or resulting objects.
Lifecycle
A Resource Resolver has a life cycle which begins with the creation of the Resource Resolver using any of the factory methods and ends with calling the close()
method. It is very important to call the close()
method once the resource resolver is not used any more to ensure any system resources are properly cleaned up.
To check whether a Resource Resolver can still be used, the isLive()
method can be called.
Q22)How to create an Event Listener ?
Event Listeners can be created using the below steps and example:
- Create a class that implements EventHandler interfaces.
- Add the following SCR annotations
- Implement public void handleEvent(Event event) method.
- E.g.- https://helpx.adobe.com/experience-manager/kb/ReplicationListener.html
- e.g http://phoolchandrasapieosoft.blogspot.in/2013/02/how-to-create-listener-in-cq55.html
Q23.) What are Clientlibs?
AEM provides Client-side Library Folders, which allow you to store your client-side code in the repository, organize it into categories, and define when and how each category of code is to be served to the client. The client-side library system then takes care of producing the correct links in your final webpage to load the correct code.
Read More – How to create a Client Lib
Q24.) What is a CQ5 overlay/override component?
Overlay/Override Component:
Creating a custom component by copying a foundation component to your project and modifying it based on the need. For example you copy image component from “/libs/foundation/components/image” to your site folder “/apps/testsite/components” by doing so you are creating a new component with is exactly same as Image component. After copying you can make changes to component based on your requirements. But the problem with this approach would be that if you are upgrading CQ then new version of CQ might have new implementation of “/libs/foundation/components/image” component than those changes will not be reflected in your “/apps/testsite/components/image” component, so you have to manually make those changes in custom component.
Extend Component:
Creating a custom component manually by creating all necessary nodes and setting value of “sling:superResourceType” property as “/libs/foundation/components/image”. By doing this you inherit all the feature of image component, even after upgrade you still inherit the features of image component.
Q25.) Difference between Parbase and Parsys?
Parbase
Parbase is a key component as it allows components to inherit attributes from other components, similar to subclasses in object oriented languages such as Java, C++, and so on. For example, when you open the/libs/foundation/components/text node in the CRXDE Lite, you see that it has a property named sling:resourceSuperType, which references the parbase component. The parbase here defines tree scripts to render images, titles, and so on, so that all components subclassed from this parbase can use this script.
Also for image component : crop,map etc inheritd
Users do not need access to the parbase.
Parsys
The paragraph system (parsys) is a compound component that allows authors to add components of different types to a page and contains all other paragraph components. Each paragraph type is represented as a component. The paragraph system itself is also a component, which contains the other paragraph components.
Q26.) Can any one tell me that how can we register the newly created servlet in Activator.java?
You can do so, by adding a custom method in Activator.java class as below:
private void registerServlet (BundleContext context, Servlet servlet, String alias) { Hashtable<String, String> props = new Hashtable<String, String>(); props.put("alias", alias); ServiceRegistration registration = context.registerService(Servlet.class.getName(), servlet, props); registrations.add(registration); }
Call this method in the start() method of Activator.java as
public void start(BundleContext context) throws Exception { registrations = new ArrayList(); registerServlet(context, new MetricsServlet(), "/metrics"); registerServlet(context, new HealthCheckServlet(), "/healthcheck"); registerServlet(context, new PingServlet(), "/ping"); registerServlet(context, new ThreadDumpServlet(), "/threads"); }
Q27.) Sling Scripts cannot be called directly in CQ5- Why?
Within Sling, scripts cannot be called directly as this would break the strict concept of a REST server; you would mix resources and representations.
If you call the representation (the script) directly you hide the resource inside your script, so the framework (Sling) no longer knows about it. Thus you lose certain features:
- automatic handling of http methods other than GET, including:
- POST, PUT, DELETE which are handled with a sling default implementation
- the POST.jsp script in your sling:resourceType location
- your code architecture is no longer as clean nor as clearly structured as it should be; of prime importance for large-scale development
Q28.) How to define a Sling-Servlet in CQ ?
There are two ways of doing this, either with a Sling-specific @SlingServlet annotation or with the more generic maven-scr-plugin annotations:
- The
@SlingServlet
annotation :@SlingServlet( resourceTypes = "sling/servlet/default", selectors = "hello", extensions = "html", methods = "GET") public class MyServlet extends SlingSafeMethodsServlet { @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { ... } }
- The
@Properties
and@Property
annotations :@Component(metatype = true) @Service(Servlet.class) @Properties({ @Property(name = "sling.servlet.resourceTypes", value = "sling/servlet/default"), @Property(name = "sling.servlet.selectors", value = "hello"), @Property(name = "sling.servlet.extensions", value = "html"), @Property(name = "sling.servlet.methods", value = "GET") }) public class MyServlet extends SlingSafeMethodsServlet { @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { ... } }
Q29.) What are xtypes and how does they useful in CQ ?
This link defines all the xtypes which are out-of-the box provided by CQ5. You may also refer to the Widget API for more details
Q30.) Difference between Overlaying and Extending a component?
There is a major difference between the two of them. Read the table below for better understanding:
Criteria | Overlaying | Extending |
Definition | Use the out-of-box component and you want to add some extra feature in it. | Copy the out-of-box component into your project structure and then extend its functionality |
Availability | Universally available across the WEM. | Not universally available across WEM as they are inherited for specific project. |
Path | /apps/foundation/components/xyz | /apps/components/xyz |
Steps to Create | They are copied from “/libs/foundation/components/ ” to “/apps/foundation/components/” |
They are extended by using
“ sling:resourceSuperType ” property
|
Recommendations | Not recommended, as it has global affect and creates problems during CQ updates | Better way to increase a component functionality |
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???
LikeLike
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