am developing a JSR286 portlet with springMVC. I have a div in my portlet which will iterate a collection in my model and showing it as below
<dl>
<c:forEach var="product" items="${productList}">
<dt>
<div><img src="<%=request.getContextPath()%>/images/banner.jpg" /></div>
<div>${product.name} - ${product.price}</div>
<div>${product.serviceOne}</div>
<div>${product.servicetwo}</div>
<div>${product.serviceThree}</div>
</dt>
</c:forEach>
</dl>
I have previous and next link. on clicking the link i need to refresh the div with new content asynchronously(using ajax). Am using jQuery for scripting. i can replace the collection in the model using resource request(resource mapping url). but i dont know how to refresh the div in the ajax success so that the new collection can be viewed in the portlet.
Techies give your suggesstions..
Created a New jsp with the iterating logic alone. In the resource request i have returned the jsp name, thereby view resolver picked the corresponding jsp from the view folder and returned the executed contents as the response. i have placed the contents to the div in tha ajax success. below is the code
@ResourceMapping("filterProducts")
public String filterProducts(Model model, ResourceRequest request,
ResourceResponse response,
@ModelAttribute("productModel") ProductModel productModel,
ModelMap modelMap) throws IOException {
model.addAttribute("productModel", updatedProductModel);
return "productDetails";
}
$.ajax({
url : fltURL,
type : 'POST',
datatype : 'html',
success : function(_html) {
$('#midcontainer').html(_html);
},
error : function() {
alert('error');
}});
<portlet:resourceURL var="filterProductsURL" id="filterProducts"></portlet:resourceURL>