How to add links in the server-side pagination?
How to add links in the server-side pagination?
I am trying to add links to the fields using server-side pagination. The links actually hit a method of a controller. We are using SPRING-PORTLET MVC for the same.
The row is populated using server side as follows:-
@JsonProperty(value = "data")
public List<Object[]> getData() {
List<Object[]> list = new ArrayList<Object[]>();
for (Msisdn msisdn : internaldata) {
list.add(new Object[] {"<a href=\"${serviceSettings}\">" + msisdn.getMsisdn() + "</a>",msisdn.getBillingType(),msisdn.getMsisdnStatus(),msisdn.getCurrentBalance()});
System.out.println("Inside getData");
}
return list;
I am using href tag there to link to a method in my framework.
JSP is as follows:
<%@page import="java.text.SimpleDateFormat, java.util.*"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%><portlet:defineObjects />
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<portlet:resourceURL var="dataTableView" id="dataTableView">
</portlet:resourceURL>
/js/jquery.dataTables.min.js">
<link href="<%=renderResponse.encodeURL(renderRequest.getContextPath())%>/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<%Date d=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("dd-MMMM-yyyy");
%>
<section>
<div class="medium-9 columns content">
<h3 class="title">Billing</h3>
<p class="text"><%=sdf.format(d.getTime()) %></p>
<hr>
<portlet:renderURL var="quickPayUrl">
<portlet:param name="action" value="quickPay" ></portlet:param>
<portlet:param name="contractId" value="${accountOverview.contractId}" ></portlet:param>
</portlet:renderURL>
<c:if test="${billingOverview.showPrepaidBillingOverview}">
<table class="no-margin-top" data-widget="sort-table">
<thead>
<tr>
<th><div><div class="large light-green"><label><spring:message code="label.topUpBalance" /></label><span class="small"><%=sdf.format(d.getTime()) %></span></div></div></th>
<th data-disable-sort><div><div class="large grey"><label><spring:message code="label.bill" /></label></div></div></th>
</tr>
</thead>
<tbody>
<tr class="no-border">
<td class="text-center large light-green">${billingOverview.totalBalance}</td>
<portlet:resourceURL var="rechargeHistoryPdf" id="rechargeHistoryPdf">
<portlet:param name="msisdn" value="${billingOver.msisdn}"/>
</portlet:resourceURL>
<td class="text-center large"><a href="#" onclick='getPdf("${rechargeHistoryPdf}")' title="View"><i class="fa fa-search-plus fa-fw"></i>View</a></td>
</tr>
</tbody>
</table>
<div class="row">
<div class="medium-12 columns text-right">
<a class="button" href="${quickPayUrl}" title="Pay">KD ${billingOverview.totalBalance } DUE - PAY NOW</a>
</div>
</div>
</c:if>
<hr class="dark-purple">
<h3 class="title">Breakdown</h3>
<table id="example" data-widget="sort-table">
<thead>
<tr>
<th><div><div><label><spring:message code="label.number" /></label></div></div></th>
<th><div><div><label><spring:message code="label.type" /></label></div></div></th>
<th><div><div><label><spring:message code="label.status" /></label></div></div></th>
<th><div><div><label><spring:message code="label.currentBalance" /></label></div></div></th>
<th data-disable-sort><div><div><label><spring:message code="label.bill" /></label></div></div></th>
</tr>
</thead>
<portlet:renderURL var="serviceSettings">
<portlet:param name="action" value="serviceSettings" />
<portlet:param name="msisdn" value="${billingOver.msisdn}"/>
</portlet:renderURL>
</table>
<div class="row">
<div class="medium-12 columns text-right">
<a class="button" href="${quickPayUrl}" title="KD 77.275 DUE - PAY NOW">KD ${billingOverview.totalBalance} ADD MORE</a>
</div>
</div>
</div>
<script>
$(document).ready(function() {
// alert("hey");
$('#example').dataTable( {
serverSide: true,
iDisplayLength: 1,
ajax : {
url: "${dataTableView}",
type: 'POST',
"fnRowCallback": function(nRow,aData,iDisplayIndex){
$('td:eq(1)', nRow).html('<a href="${serviceSettings}' + aData[1] + '">' +
aData[1] + '</a>');
return nRow;
}
//success:function(data){
//alert(data);
//datatype: 'json',
//alert(response);
//var bean = jQuery.parseJSON(response);
// alert(bean);
// }
}
}
);
});
</script>
</section>
In my JSP I am using "fnRowCallback" attribute but it is of no help. Where am I going wrong, It wouldn't just hit the right method of the controller. Where am I going wrong? Please help.
Answers
Hi
I am facing the similar issue?. Any update on this thread?
Hi Kaviya,
I am trying to figure out this issue. If you find the solution, please do let me know. I would do the same.