Showing posts with label aem cq components basics. Show all posts
Showing posts with label aem cq components basics. Show all posts

Tuesday, 10 June 2014

Apache sling in AEM/CQ


Apache sling

Content centric application based on content repository to store & manage content. REST based and supports OSGi bundles.
Sling finds the resources via url decompositions.
>>> read more at: http://sling.apache.org/documentation/the-sling-engine/url-decomposition.html

A general uri can be decomposed as below.
URI                                           -resource path               -selectors          -extensions       -suffix path
/a/b.s1.s2.html/c/d.s.txt /a/b                  s1.s2                   html               /c/d.s.txt          

Now let us see some real examples:
Eg1 : http://localhost:4505/cf#/content/demos.html
Here,Resource Path /content/demos
selector = null
extension = html

Resource path resolution: It uses the given path
If no selectors given then below approach used to find the resource.
1) Is there any html /JSP under the directory?
2) is there any node name matching the JSP name?
3) is there any method JSP files? (GET.JSP/post.JSP)?
If nothing above matches,
4) Then it checks for sling property and path related
Note: Whatever may be the resource look up level, when look up resource happens, always the search starts from our base project path directories.
Looking order of folders reach back to app> libs

Eg 2: uri: content/demo.print.html
RP= /content/demo
selector print
extn=html
It goes to relevant node, then gets resource path's path property then fetches result.

Components & Inheritance

Components can inherit properties, scripts, dialogs and other objects from base components.
All built in components available at /libs/foundation/components.CQ uses single inheritance, where there can only be a single super type for each component.  Inheritance in CQ is done by 'sling:resourceSuperType' attribute.

Components in Real time projects
-------------------------------------------------
Base comp will always inherit page component
base.jsp will hold header.jsp,footer.jsp,content.jsp etc.