I'm working on online shopping application using struts 2, mysql , jquery, jsp, bootstrap, gson and tomcat.
I have Java entity called Product, controller action that return json array of products and jsp page that calls that action through ajax and displays all products to user.
What I don't understand is to how display such json array.
I've googled for JQuery Datatables plugin as it propose filtering and pagination, but I don't get how it should be configured, because I want to group information not by product fields, but to group by every product entity like in the following picture:

If there is a better plugins or other solutions please suggest them, but please note that in future development I want to add an image of Product.
Product entity:
public class Product{
private long id;
private String name;
private double price;
private long storeId;
//getters and setters
}
And action controller class ViewAllProducts:
public class ViewAllProducts extends ActionSupport {
@Override
public String execute() throws Exception {
LOG.trace("Start execute");
Collection<Product> products = productDAO.findAll();
Gson gson = new Gson();
JsonElement element = gson.toJsonTree(products,
new TypeToken<Collection<Product>>() {
}.getType());
JsonArray jsonArray = element.getAsJsonArray();
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().print(jsonArray);
LOG.trace("Finished execute");
return null;
}
}
This is my code from jsp page where I do Ajax call for this action:
<%@ include file="/WEB-INF/jspf/directive/page.jspf"%>
<%@ include file="/WEB-INF/jspf/directive/taglib.jspf"%>
<html>
<%@ include file="/WEB-INF/jspf/head.jspf"%>
<body>
<%@ include file="/WEB-INF/jspf/menu.jspf"%>
<div class="container" style="width: 40%">
<div id="results"></div>
</div>
<script type="text/javascript">
$.ajax({
type : 'GET',
dataType : 'json',
url : 'product/upload_products',
success : function(products) {
$.each(products, function(index, product) {
$('#results').append(?????);
});
}
},
})
</script>
</body>
</html>
Json array output example:
[{"name":"Amet Ultricies Incorporated","price":679.71,"storeId":1,"id":1},
{"name":"Ut Nisi A PC","price":1133.43,"storeId":1,"id":2},
{"name":"Ligula Limited","price":156.66,"storeId":1,"id":100}]
dust.js, if so would you explain ?