// for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex"
if (viewIndexParam.equals("viewIndex" + "_" + paginatorNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber;
if (viewSizeParam.equals("viewSize" + "_" + paginatorNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;
ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
Map<String, Object> inputFields = UtilGenerics.toMap(context.get("requestParameters"));
// strip out any multi form fields if the form is of type multi
if (modelForm.getType().equals("multi")) {
inputFields = UtilHttp.removeMultiFormParameters(inputFields);
}
String queryString = UtilHttp.urlEncodeArgs(inputFields);
// strip legacy viewIndex/viewSize params from the query string
queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber);
// strip parametrized index/size params from the query string
HashSet<String> paramNames = new HashSet<String>();
paramNames.add(viewIndexParam);
paramNames.add(viewSizeParam);
queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames);
String anchor = "";
String paginateAnchor = modelForm.getPaginateTargetAnchor();
if (paginateAnchor != null) anchor = "#" + paginateAnchor;
// preparing the link text, so that later in the code we can reuse this and just add the viewIndex
String prepLinkText = "";
prepLinkText = targetService;
if (prepLinkText.indexOf("?") < 0) {
prepLinkText += "?";
} else if (!prepLinkText.endsWith("?")) {
prepLinkText += "&";
}
if (!UtilValidate.isEmpty(queryString) && !queryString.equals("null")) {
prepLinkText += queryString + "&";
}
prepLinkText += viewSizeParam + "=" + viewSize + "&" + viewIndexParam + "=";
String linkText;
// The current screenlet title bar navigation syling requires rendering
// these links in reverse order
// Last button
String paginateLastStyle = modelForm.getPaginateLastStyle();
String paginateLastLabel = modelForm.getPaginateLastLabel(context);
String lastLinkUrl = "";
if (highIndex < listSize) {
int page = (listSize / viewSize);
linkText = prepLinkText + page + anchor;
lastLinkUrl = rh.makeLink(request, response, linkText);
}
String paginateNextStyle = modelForm.getPaginateNextStyle();
String paginateNextLabel = modelForm.getPaginateNextLabel(context);
String nextLinkUrl = "";
if (highIndex < listSize) {
linkText = prepLinkText + (viewIndex + 1) + anchor;
// - make the link
nextLinkUrl = rh.makeLink(request, response, linkText);
}
String paginatePreviousStyle = modelForm.getPaginatePreviousStyle();
String paginatePreviousLabel = modelForm.getPaginatePreviousLabel(context);
String previousLinkUrl = "";
if (viewIndex > 0) {
linkText = prepLinkText + (viewIndex - 1) + anchor;
previousLinkUrl = rh.makeLink(request, response, linkText);
}
String paginateFirstStyle = modelForm.getPaginateFirstStyle();
String paginateFirstLabel = modelForm.getPaginateFirstLabel(context);
String firstLinkUrl = "";
if (viewIndex > 0) {
linkText = prepLinkText + 0 + anchor;
firstLinkUrl = rh.makeLink(request, response, linkText);
}
StringWriter sr = new StringWriter();
sr.append("<@renderScreenletPaginateMenu ");
sr.append("lowIndex=\"");