Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (66 sloc) 2.753 kb
<%@ taglib uri="" prefix="c"%>
<%@ taglib uri="" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" lang="pl" xml:lang="pl">
<title>Embedded JSON</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="<c:url value="/resources/css/bootstrap.min.css" />" type="text/css"></link>
<script type="text/javascript" src="<c:url value="/resources/js/jquery.min.js" />"></script>
var initialProducts = ${productJSON};
// Fetch products using Ajax call and update html.
function getProducts(page, pageSize) {
// Use setTimeout to simulate high network latency
setTimeout( function() {
url: 'api/product/list?page=' + page + '&pageSize=' + pageSize,
success: function (data) {
console.log("Successful product Ajax call with data:");
}, 400);
function updateProducts(products) {
var productTable = $('#productTable');
// Yes, you should probably use a decent JS templating system!
$.each(products, function(index, product) {
// On document.ready, initialize link handlers and render first products.
$(function () {
$.each($('.pagingLink'), function(index, link) {
console.log('Updating click handler of link ' + link + ' at index ' + index);
$(link).click(function() { getProducts(index+1, 3); return false; });
<table class="table table-striped table-bordered">
<tbody id="productTable" />
<c:if test="${pageIndices.size() > 1}">
<div id="paging">
<c:forEach var="pageIndex" items="${pageIndices}">
<a href="#" class="pagingLink"><c:out value="${pageIndex}" /></a>
Jump to Line
Something went wrong with that request. Please try again.