@arindam6600 :
@SlingModel:
Sling Models are "pure" POJOs which maps Sling objects (resources, request objects etc.).
They allow you to map resource properties, assign default values, inject OSGi services and much more.
Predominently, if you want to use the property values in Sightly , you can use data-sly-use and call the slingmodel to retrive the property values, while retrieving you can make changes to the values if needed.
We are using @Model annotation to specify that this model class is a Sling Model. Each data member is annotated with @Inject. This class will be mapped to a resource in JCR.
@sling servlet :
Sling servlet can be registered by using paths or resourceType.
Sling servlet are basically used when front end developers need to make ajax call and want to get response in form of json
2
3
4
5
6
7
8
9
10
11
12
13
|
$.ajax({
type : "GET" ,
url : '/bin/custom/path' ,
success : function(data, textStatus, jqXHR) {
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
}
});
|
@SuppressWarnings
(
"serial"
)
@SlingServlet
(paths =
"/bin/custom/path"
)
public
class
SimpleServlet
extends
SlingSafeMethodsServlet {
}
.
Thanks,
Siva