Posts

Data-sly-list & Data-sly-repeat

Image
  AEM Sightly : Data-sly-list : the most powerful block statement of sightly which iterate the collection return from the slingModel.  Data-sly-list can handle any kind of collection like: Example : <div  data-sly-use. variable_name =“com.aem.package_name.core.models.Interfaceclass_name”></div>// this is used to call the slingModel <div data-sly-list. item =“${ variable_name . InterfaceMethod_Name}”> // item is the default variable provided by Slightly & you can give any name ${ item } </div> *note: Map don’t give ordered list, It gives random list. —> We can control loop’s in slightly using begin, end. Example: <div data-sly-list. item =“${ variable_name .InterfaceMethod_Name @ begin =0, end =3}”>  // the loop gives 4 values ${ item } </div>  —> Slightly provide some methods like: count, even, odd, middle…etc. Example: <div data-sly-list. item =“${ variable_name .InterfaceMethod_Name}”> ${ ite...

List Child pages with Sling model

Image
  List Child pages with Sling model : Step1 : Create a Component with mandatory fields(cq:dialog & component.html)   I Created a component with name pageinfo with in that create cq:dialog and rename the .jsp file to .html Step2 : Create a Interface class, Here we created with name PageInfo.java package com.myproject.aem.core.models ; import com.day.cq.wcm.api.Page ; import java.util.Iterator ; import java.util.List ; public interface PageInfo {     public List<Page> getPageS () ;     public Iterator<Page> getPageChild () ; } Step3 : Create Implementation class, Here we created  with name PageInfoImpl.java package com.myproject.aem.core.models ; import com.day.cq.wcm.api.Page ; import com.day.cq.wcm.api.PageManager ; import org.apache.sling.api.SlingHttpServletRequest ; import org.apache.sling.api.resource.Resource ; import org.apache.sling.models.annotations.DefaultInjectionStrategy ; import org.apache.sli...

SlingModel

Image
  Sling Model: Component With Sling Model: 1.Front End 2.Back End Front End Contain all the Rendering Logic you have and the Back End Controller will process the business logic and return data to Front End. Front End : To Create Component we need to follow the following steps. author.html and cq:dialog are mandatory fields ,this is the starting point of rendering Logic, these dialogs take input from content author and display on page. clientlibs : If you have any ui specific like javascript, css, svg and other stuff will be in clientlibs, you should have those component related stuff in  your component itself. It’s adobe Recommended. You can have any number of clientlibs in your component. cq:design_dialog : this is same as cq:dialog but the only difference  is the design_dialog save your values at Site level(means at a common place), So these values or properties available through-out the site. but cq:dialog values or properties available only on  ...

Java Packages

Java Packages: A Java Package is a simple kind of a folder which contain a similar   kind of classes, Suppose a classes which are belongs to some functionality will be there in one package the other classes which are belongs to other functionality belongs to other packages. And later if you want to get that class in some other class we will refer that class by using Package Name, So a Java Package is a collection of classes,Interfaces or some files. In realTime the PackageName are like com.ProjectName.CompanyName like this . So If there are two packages with classes:  Package1 {classA, classB,….} & Package2{classX, classY,….}: To access classA from Package2 we need Import & extend keywords Syntax: Import PackageName.className; classX extend classA { // here we can use classA } How to create Sub-Package: Right click on parent package and click on   New—>Package: give name as  “Parent-PackageName.Sub-PackageName” and Finish. These ...

Java ArrayList

  ArrayList: (Derived Data Type / Collections) —> A normal Array have some limitations: 1.It can store same DataType                                 elements/values, 2.It is Fixed Size. —>To Overcome the above limitations we can use ArrayList Which can store multiple         DataType elements/values & it as no-Limit of Size. —>An ArrayList is a predefined Class, So we can call Methods using Object. * Note:   the name of the Object becomes the name of the ArrayList. ArrayList Declaration : Two ways we can declare ArrayList   To store any type of elements.   : ArrayList obj=new ArrayList();         Example: ArrayList list = new ArrayList();                              2.  To store same type of elements :    ...

Java HashMap

  HashMap: HashMap contain data in form of : Keys & Values = Pair(we call it as Pair) Key’s should be Unique and Values can be duplicate. The Keys and Values can be any DataType. To Store Pairs in a variable that should be a “ Map.Entry ” DataType like Object datatype in ArrayList. To read the values from the “ Map.Entry Variable ” we should use methods like: variable.getKey(); variable.getValue() ; * Note:   the name of the Object becomes the name of the HashMap.      ▪  HashMap Declaration : Two ways we can declare HashMap. To Store any DataType of pairs(key, value): HashMap objectName = new HashMap(); Example: HashMap obj = new HashMap();     2.  To Store Required DataType of pairs(key, value):             HashMap <key _DataType, value_DataType>   objectName = new HashMap                <key _DataType, value_DataType> ();  ...