1) Currently i'm providing static URL path as datasource instead of servlet path, i tried the below method from pagination but not working
dataSource: function(done) {
$.ajax({
type: 'GET',
url: '/bin/amica/searchResultsServlet?q=' + 'queryString',
success: function(response) {
done(response);
}
});
}
2) How to include query parameters in HTL script. For example I need to get the parameter value 'q'' attribute it to queryString dynamically after every request?
<script>
$('.demo').pagination({
dataSource: 'http://localhost:8080/bin/amica/searchServlet?q= + 'queryString',
locator: 'searchResults',
pageSize: 5,
prevText: "Previous",
nextText: "Next",
callback: function(data, pagination) {
var html = template(data);
$('.datacontainer').html(html);
}
</script>
Views
Replies
Total Likes
What are you trying to do. As far as i can see - you are performing a GET operation to a Servlet from HTL component. Now, what - do you want to write the data returned from the GET operation to the HTL component?
Views
Replies
Total Likes
Hi,
Just sharing few thoughts on above :
1] It is preferred to use servlet resolution by resource type[sling.servlet.resourceTypes] than by path[which you have implemented].
2] For pagination[probably another way without servlet would be to] use the result provided by the querbuilder "searchResult = query.getResult();" in the model where querybuilder is used and get the pagination to work.
3] To get the query parameter in model class,
@SlingObject
private SlingHttpServletRequest request;
searchTerm = request.getParameter("q"); should work.
Views
Replies
Total Likes