Skip to main content

Posts

Showing posts from January, 2017

Using SlingModel

Sling Model are excellent way to Map your resources to Class or Interface. Many of us has  worked in  ORM frameworks (Hibernate, Ibatis...) ,where we maintain a direct mapping between the data fields and plain old java object class either through annotation or through configuration file.We can achieve the same functionality where we can map resources directly POJO/Interface using Sling Model capability, It is purely annotation driven and creating a Sling Model is quite simple , we need to add @Model class level annotation , with adaptable type specified.The annotation can be applied to either class or interface. Each field or method to be used in injected by Sling Model are annotated with @Inject annotations. As there support for both Interface and Class , we can use it as per the requirement ,mostly interface based sling model would suffice with less code. How to pass parameters to Sling Model Sling Model offers the flexibility to passing  parameter, the pa