@Test public void renderNextPrevUsesQueryString(@Mocked ModelForm modelForm) throws IOException { final String targetService = ""; final String qbeString = "field1=value1&amp;field2=value2+with+spaces"; final String linkFromQbeString = "LinkFromQBEString"; new Expectations() { { modelForm.getPaginateTarget(withNotNull()); result = targetService; requestHandler.makeLink(null, null, withSubstring(qbeString)); result = linkFromQbeString; } }; final Map<String, Object> context = new HashMap<>(); context.put("_QBESTRING_", qbeString); context.put("listSize", 100); macroFormRenderer.renderNextPrev(appendable, context, modelForm); assertAndGetMacroString("renderNextPrev", ImmutableMap.of("nextUrl", linkFromQbeString)); }
public void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm) { boolean ajaxEnabled = false; List<ModelForm.UpdateArea> updateAreas = modelForm.getOnPaginateUpdateAreas(); String targetService = modelForm.getPaginateTarget(context); if (this.javaScriptEnabled) { if (UtilValidate.isNotEmpty(updateAreas)) { ajaxEnabled = true; } } if (targetService == null) { targetService = "${targetService}"; } if (UtilValidate.isEmpty(targetService) && updateAreas == null) { Debug.logWarning("Cannot paginate because TargetService is empty for the form: " + modelForm.getName(), MODULE); return; } int paginatorNumber = WidgetWorker.getPaginatorNumber(context); String viewIndexParam = modelForm.getMultiPaginateIndexField(context); String viewSizeParam = modelForm.getMultiPaginateSizeField(context); int viewIndex = Paginator.getViewIndex(modelForm, context); int viewSize = Paginator.getViewSize(modelForm, context); int listSize = Paginator.getListSize(context); int lowIndex = Paginator.getLowIndex(context); int highIndex = Paginator.getHighIndex(context); int actualPageSize = Paginator.getActualPageSize(context); Map<String, String> uiLabelMap = UtilGenerics.cast(context.get("uiLabelMap")); String pageLabel = ""; String commonDisplaying = ""; if (uiLabelMap == null) { Debug.logWarning("Could not find uiLabelMap in context", MODULE); } else { pageLabel = uiLabelMap.get("CommonPage"); Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", lowIndex + 1, "highCount", lowIndex + actualPageSize, "total", listSize); commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale")); } if (("viewIndex" + "_" + paginatorNumber).equals(viewIndexParam)) { viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber; } if (("viewSize" + "_" + paginatorNumber).equals(viewSizeParam)) { viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber; } String str = (String) context.get("_QBESTRING_"); String tokenValue = CsrfUtil.generateTokenForNonAjax(request, targetService); str = CsrfUtil.addOrUpdateTokenInQueryString(str, tokenValue); String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber); Set<String> paramNames = new HashSet<>(); paramNames.add(viewIndexParam); paramNames.add(viewSizeParam); queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames); String anchor = ""; String paginateAnchor = modelForm.getPaginateTargetAnchor(); if (UtilValidate.isNotEmpty(paginateAnchor)) { anchor = "#" + paginateAnchor; } String urlPath = UtilHttp.removeQueryStringFromTarget(targetService); String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService); String prepLinkSizeText; if (UtilValidate.isNotEmpty(queryString)) { queryString = UtilHttp.encodeAmpersands(queryString); } if (prepLinkText.indexOf('?') < 0) { prepLinkText += "?"; } else if (!prepLinkText.endsWith("?")) { prepLinkText += "&amp;"; } if (UtilValidate.isNotEmpty(queryString) && !"null".equals(queryString)) { prepLinkText += queryString + "&amp;"; } prepLinkSizeText = prepLinkText + viewSizeParam + "='+this.value+'" + "&amp;" + viewIndexParam + "=0"; prepLinkText += viewSizeParam + "=" + viewSize + "&amp;" + viewIndexParam + "="; if (ajaxEnabled) { prepLinkText = prepLinkText.replace("?", ""); prepLinkText = prepLinkText.replace("&amp;", "&"); } String linkText; String paginateStyle = modelForm.getPaginateStyle(); String paginateFirstStyle = modelForm.getPaginateFirstStyle(); String paginateFirstLabel = modelForm.getPaginateFirstLabel(context); String firstUrl = ""; String ajaxFirstUrl = ""; String paginatePreviousStyle = modelForm.getPaginatePreviousStyle(); String paginatePreviousLabel = modelForm.getPaginatePreviousLabel(context); String previousUrl = ""; String ajaxPreviousUrl = ""; String selectUrl = ""; String ajaxSelectUrl = ""; String paginateViewSizeLabel = modelForm.getPaginateViewSizeLabel(context); String selectSizeUrl = ""; String ajaxSelectSizeUrl = ""; String paginateNextStyle = modelForm.getPaginateNextStyle(); String paginateNextLabel = modelForm.getPaginateNextLabel(context); String nextUrl = ""; String ajaxNextUrl = ""; String paginateLastStyle = modelForm.getPaginateLastStyle(); String paginateLastLabel = modelForm.getPaginateLastLabel(context); String lastUrl = ""; String ajaxLastUrl = ""; if (viewIndex > 0) { if (ajaxEnabled) { ajaxFirstUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + 0 + anchor, context); } else { linkText = prepLinkText + 0 + anchor; firstUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (viewIndex > 0) { if (ajaxEnabled) { ajaxPreviousUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex - 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex - 1) + anchor; previousUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + "' + this.value + '", context); } else { linkText = prepLinkText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { if (ajaxEnabled) { ajaxNextUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex + 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex + 1) + anchor; nextUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize); if (ajaxEnabled) { ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + lastIndex + anchor, context); } else { linkText = prepLinkText + lastIndex + anchor; lastUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectSizeUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkSizeText + anchor, context); } else { linkText = prepLinkSizeText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectSizeUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } StringWriter sr = new StringWriter(); sr.append("<@renderNextPrev "); sr.append(" paginateStyle=\""); sr.append(paginateStyle); sr.append("\" paginateFirstStyle=\""); sr.append(paginateFirstStyle); sr.append("\" viewIndex="); sr.append(Integer.toString(viewIndex)); sr.append(" highIndex="); sr.append(Integer.toString(highIndex)); sr.append(" listSize="); sr.append(Integer.toString(listSize)); sr.append(" viewSize="); sr.append(Integer.toString(viewSize)); sr.append(" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" javaScriptEnabled="); sr.append(Boolean.toString(javaScriptEnabled)); sr.append(" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" firstUrl=\""); sr.append(firstUrl); sr.append("\" paginateFirstLabel=\""); sr.append(paginateFirstLabel); sr.append("\" paginatePreviousStyle=\""); sr.append(paginatePreviousStyle); sr.append("\" ajaxPreviousUrl=\""); sr.append(ajaxPreviousUrl); sr.append("\" previousUrl=\""); sr.append(previousUrl); sr.append("\" paginatePreviousLabel=\""); sr.append(paginatePreviousLabel); sr.append("\" pageLabel=\""); sr.append(pageLabel); sr.append("\" ajaxSelectUrl=\""); sr.append(ajaxSelectUrl); sr.append("\" selectUrl=\""); sr.append(selectUrl); sr.append("\" ajaxSelectSizeUrl=\""); sr.append(ajaxSelectSizeUrl); sr.append("\" selectSizeUrl=\""); sr.append(selectSizeUrl); sr.append("\" commonDisplaying=\""); sr.append(commonDisplaying); sr.append("\" paginateNextStyle=\""); sr.append(paginateNextStyle); sr.append("\" ajaxNextUrl=\""); sr.append(ajaxNextUrl); sr.append("\" nextUrl=\""); sr.append(nextUrl); sr.append("\" paginateNextLabel=\""); sr.append(paginateNextLabel); sr.append("\" paginateLastStyle=\""); sr.append(paginateLastStyle); sr.append("\" ajaxLastUrl=\""); sr.append(ajaxLastUrl); sr.append("\" lastUrl=\""); sr.append(lastUrl); sr.append("\" paginateLastLabel=\""); sr.append(paginateLastLabel); sr.append("\" paginateViewSizeLabel=\""); sr.append(paginateViewSizeLabel); sr.append("\" />"); executeMacro(writer, sr.toString()); }
MacroFormRenderer implements FormStringRenderer { public void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm) { boolean ajaxEnabled = false; List<ModelForm.UpdateArea> updateAreas = modelForm.getOnPaginateUpdateAreas(); String targetService = modelForm.getPaginateTarget(context); if (this.javaScriptEnabled) { if (UtilValidate.isNotEmpty(updateAreas)) { ajaxEnabled = true; } } if (targetService == null) { targetService = "${targetService}"; } if (UtilValidate.isEmpty(targetService) && updateAreas == null) { Debug.logWarning("Cannot paginate because TargetService is empty for the form: " + modelForm.getName(), MODULE); return; } int paginatorNumber = WidgetWorker.getPaginatorNumber(context); String viewIndexParam = modelForm.getMultiPaginateIndexField(context); String viewSizeParam = modelForm.getMultiPaginateSizeField(context); int viewIndex = Paginator.getViewIndex(modelForm, context); int viewSize = Paginator.getViewSize(modelForm, context); int listSize = Paginator.getListSize(context); int lowIndex = Paginator.getLowIndex(context); int highIndex = Paginator.getHighIndex(context); int actualPageSize = Paginator.getActualPageSize(context); Map<String, String> uiLabelMap = UtilGenerics.cast(context.get("uiLabelMap")); String pageLabel = ""; String commonDisplaying = ""; if (uiLabelMap == null) { Debug.logWarning("Could not find uiLabelMap in context", MODULE); } else { pageLabel = uiLabelMap.get("CommonPage"); Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", lowIndex + 1, "highCount", lowIndex + actualPageSize, "total", listSize); commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale")); } if (("viewIndex" + "_" + paginatorNumber).equals(viewIndexParam)) { viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber; } if (("viewSize" + "_" + paginatorNumber).equals(viewSizeParam)) { viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber; } String str = (String) context.get("_QBESTRING_"); String tokenValue = CsrfUtil.generateTokenForNonAjax(request, targetService); str = CsrfUtil.addOrUpdateTokenInQueryString(str, tokenValue); String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber); Set<String> paramNames = new HashSet<>(); paramNames.add(viewIndexParam); paramNames.add(viewSizeParam); queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames); String anchor = ""; String paginateAnchor = modelForm.getPaginateTargetAnchor(); if (UtilValidate.isNotEmpty(paginateAnchor)) { anchor = "#" + paginateAnchor; } String urlPath = UtilHttp.removeQueryStringFromTarget(targetService); String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService); String prepLinkSizeText; if (UtilValidate.isNotEmpty(queryString)) { queryString = UtilHttp.encodeAmpersands(queryString); } if (prepLinkText.indexOf('?') < 0) { prepLinkText += "?"; } else if (!prepLinkText.endsWith("?")) { prepLinkText += "&amp;"; } if (UtilValidate.isNotEmpty(queryString) && !"null".equals(queryString)) { prepLinkText += queryString + "&amp;"; } prepLinkSizeText = prepLinkText + viewSizeParam + "='+this.value+'" + "&amp;" + viewIndexParam + "=0"; prepLinkText += viewSizeParam + "=" + viewSize + "&amp;" + viewIndexParam + "="; if (ajaxEnabled) { prepLinkText = prepLinkText.replace("?", ""); prepLinkText = prepLinkText.replace("&amp;", "&"); } String linkText; String paginateStyle = modelForm.getPaginateStyle(); String paginateFirstStyle = modelForm.getPaginateFirstStyle(); String paginateFirstLabel = modelForm.getPaginateFirstLabel(context); String firstUrl = ""; String ajaxFirstUrl = ""; String paginatePreviousStyle = modelForm.getPaginatePreviousStyle(); String paginatePreviousLabel = modelForm.getPaginatePreviousLabel(context); String previousUrl = ""; String ajaxPreviousUrl = ""; String selectUrl = ""; String ajaxSelectUrl = ""; String paginateViewSizeLabel = modelForm.getPaginateViewSizeLabel(context); String selectSizeUrl = ""; String ajaxSelectSizeUrl = ""; String paginateNextStyle = modelForm.getPaginateNextStyle(); String paginateNextLabel = modelForm.getPaginateNextLabel(context); String nextUrl = ""; String ajaxNextUrl = ""; String paginateLastStyle = modelForm.getPaginateLastStyle(); String paginateLastLabel = modelForm.getPaginateLastLabel(context); String lastUrl = ""; String ajaxLastUrl = ""; if (viewIndex > 0) { if (ajaxEnabled) { ajaxFirstUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + 0 + anchor, context); } else { linkText = prepLinkText + 0 + anchor; firstUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (viewIndex > 0) { if (ajaxEnabled) { ajaxPreviousUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex - 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex - 1) + anchor; previousUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + "' + this.value + '", context); } else { linkText = prepLinkText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { if (ajaxEnabled) { ajaxNextUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex + 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex + 1) + anchor; nextUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize); if (ajaxEnabled) { ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + lastIndex + anchor, context); } else { linkText = prepLinkText + lastIndex + anchor; lastUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectSizeUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkSizeText + anchor, context); } else { linkText = prepLinkSizeText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectSizeUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } StringWriter sr = new StringWriter(); sr.append("<@renderNextPrev "); sr.append(" paginateStyle=\""); sr.append(paginateStyle); sr.append("\" paginateFirstStyle=\""); sr.append(paginateFirstStyle); sr.append("\" viewIndex="); sr.append(Integer.toString(viewIndex)); sr.append(" highIndex="); sr.append(Integer.toString(highIndex)); sr.append(" listSize="); sr.append(Integer.toString(listSize)); sr.append(" viewSize="); sr.append(Integer.toString(viewSize)); sr.append(" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" javaScriptEnabled="); sr.append(Boolean.toString(javaScriptEnabled)); sr.append(" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" firstUrl=\""); sr.append(firstUrl); sr.append("\" paginateFirstLabel=\""); sr.append(paginateFirstLabel); sr.append("\" paginatePreviousStyle=\""); sr.append(paginatePreviousStyle); sr.append("\" ajaxPreviousUrl=\""); sr.append(ajaxPreviousUrl); sr.append("\" previousUrl=\""); sr.append(previousUrl); sr.append("\" paginatePreviousLabel=\""); sr.append(paginatePreviousLabel); sr.append("\" pageLabel=\""); sr.append(pageLabel); sr.append("\" ajaxSelectUrl=\""); sr.append(ajaxSelectUrl); sr.append("\" selectUrl=\""); sr.append(selectUrl); sr.append("\" ajaxSelectSizeUrl=\""); sr.append(ajaxSelectSizeUrl); sr.append("\" selectSizeUrl=\""); sr.append(selectSizeUrl); sr.append("\" commonDisplaying=\""); sr.append(commonDisplaying); sr.append("\" paginateNextStyle=\""); sr.append(paginateNextStyle); sr.append("\" ajaxNextUrl=\""); sr.append(ajaxNextUrl); sr.append("\" nextUrl=\""); sr.append(nextUrl); sr.append("\" paginateNextLabel=\""); sr.append(paginateNextLabel); sr.append("\" paginateLastStyle=\""); sr.append(paginateLastStyle); sr.append("\" ajaxLastUrl=\""); sr.append(ajaxLastUrl); sr.append("\" lastUrl=\""); sr.append(lastUrl); sr.append("\" paginateLastLabel=\""); sr.append(paginateLastLabel); sr.append("\" paginateViewSizeLabel=\""); sr.append(paginateViewSizeLabel); sr.append("\" />"); executeMacro(writer, sr.toString()); } }
MacroFormRenderer implements FormStringRenderer { public void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm) { boolean ajaxEnabled = false; List<ModelForm.UpdateArea> updateAreas = modelForm.getOnPaginateUpdateAreas(); String targetService = modelForm.getPaginateTarget(context); if (this.javaScriptEnabled) { if (UtilValidate.isNotEmpty(updateAreas)) { ajaxEnabled = true; } } if (targetService == null) { targetService = "${targetService}"; } if (UtilValidate.isEmpty(targetService) && updateAreas == null) { Debug.logWarning("Cannot paginate because TargetService is empty for the form: " + modelForm.getName(), MODULE); return; } int paginatorNumber = WidgetWorker.getPaginatorNumber(context); String viewIndexParam = modelForm.getMultiPaginateIndexField(context); String viewSizeParam = modelForm.getMultiPaginateSizeField(context); int viewIndex = Paginator.getViewIndex(modelForm, context); int viewSize = Paginator.getViewSize(modelForm, context); int listSize = Paginator.getListSize(context); int lowIndex = Paginator.getLowIndex(context); int highIndex = Paginator.getHighIndex(context); int actualPageSize = Paginator.getActualPageSize(context); Map<String, String> uiLabelMap = UtilGenerics.cast(context.get("uiLabelMap")); String pageLabel = ""; String commonDisplaying = ""; if (uiLabelMap == null) { Debug.logWarning("Could not find uiLabelMap in context", MODULE); } else { pageLabel = uiLabelMap.get("CommonPage"); Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", lowIndex + 1, "highCount", lowIndex + actualPageSize, "total", listSize); commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale")); } if (("viewIndex" + "_" + paginatorNumber).equals(viewIndexParam)) { viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber; } if (("viewSize" + "_" + paginatorNumber).equals(viewSizeParam)) { viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber; } String str = (String) context.get("_QBESTRING_"); String tokenValue = CsrfUtil.generateTokenForNonAjax(request, targetService); str = CsrfUtil.addOrUpdateTokenInQueryString(str, tokenValue); String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber); Set<String> paramNames = new HashSet<>(); paramNames.add(viewIndexParam); paramNames.add(viewSizeParam); queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames); String anchor = ""; String paginateAnchor = modelForm.getPaginateTargetAnchor(); if (UtilValidate.isNotEmpty(paginateAnchor)) { anchor = "#" + paginateAnchor; } String urlPath = UtilHttp.removeQueryStringFromTarget(targetService); String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService); String prepLinkSizeText; if (UtilValidate.isNotEmpty(queryString)) { queryString = UtilHttp.encodeAmpersands(queryString); } if (prepLinkText.indexOf('?') < 0) { prepLinkText += "?"; } else if (!prepLinkText.endsWith("?")) { prepLinkText += "&amp;"; } if (UtilValidate.isNotEmpty(queryString) && !"null".equals(queryString)) { prepLinkText += queryString + "&amp;"; } prepLinkSizeText = prepLinkText + viewSizeParam + "='+this.value+'" + "&amp;" + viewIndexParam + "=0"; prepLinkText += viewSizeParam + "=" + viewSize + "&amp;" + viewIndexParam + "="; if (ajaxEnabled) { prepLinkText = prepLinkText.replace("?", ""); prepLinkText = prepLinkText.replace("&amp;", "&"); } String linkText; String paginateStyle = modelForm.getPaginateStyle(); String paginateFirstStyle = modelForm.getPaginateFirstStyle(); String paginateFirstLabel = modelForm.getPaginateFirstLabel(context); String firstUrl = ""; String ajaxFirstUrl = ""; String paginatePreviousStyle = modelForm.getPaginatePreviousStyle(); String paginatePreviousLabel = modelForm.getPaginatePreviousLabel(context); String previousUrl = ""; String ajaxPreviousUrl = ""; String selectUrl = ""; String ajaxSelectUrl = ""; String paginateViewSizeLabel = modelForm.getPaginateViewSizeLabel(context); String selectSizeUrl = ""; String ajaxSelectSizeUrl = ""; String paginateNextStyle = modelForm.getPaginateNextStyle(); String paginateNextLabel = modelForm.getPaginateNextLabel(context); String nextUrl = ""; String ajaxNextUrl = ""; String paginateLastStyle = modelForm.getPaginateLastStyle(); String paginateLastLabel = modelForm.getPaginateLastLabel(context); String lastUrl = ""; String ajaxLastUrl = ""; if (viewIndex > 0) { if (ajaxEnabled) { ajaxFirstUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + 0 + anchor, context); } else { linkText = prepLinkText + 0 + anchor; firstUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (viewIndex > 0) { if (ajaxEnabled) { ajaxPreviousUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex - 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex - 1) + anchor; previousUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + "' + this.value + '", context); } else { linkText = prepLinkText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { if (ajaxEnabled) { ajaxNextUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex + 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex + 1) + anchor; nextUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize); if (ajaxEnabled) { ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + lastIndex + anchor, context); } else { linkText = prepLinkText + lastIndex + anchor; lastUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectSizeUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkSizeText + anchor, context); } else { linkText = prepLinkSizeText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectSizeUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } StringWriter sr = new StringWriter(); sr.append("<@renderNextPrev "); sr.append(" paginateStyle=\""); sr.append(paginateStyle); sr.append("\" paginateFirstStyle=\""); sr.append(paginateFirstStyle); sr.append("\" viewIndex="); sr.append(Integer.toString(viewIndex)); sr.append(" highIndex="); sr.append(Integer.toString(highIndex)); sr.append(" listSize="); sr.append(Integer.toString(listSize)); sr.append(" viewSize="); sr.append(Integer.toString(viewSize)); sr.append(" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" javaScriptEnabled="); sr.append(Boolean.toString(javaScriptEnabled)); sr.append(" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" firstUrl=\""); sr.append(firstUrl); sr.append("\" paginateFirstLabel=\""); sr.append(paginateFirstLabel); sr.append("\" paginatePreviousStyle=\""); sr.append(paginatePreviousStyle); sr.append("\" ajaxPreviousUrl=\""); sr.append(ajaxPreviousUrl); sr.append("\" previousUrl=\""); sr.append(previousUrl); sr.append("\" paginatePreviousLabel=\""); sr.append(paginatePreviousLabel); sr.append("\" pageLabel=\""); sr.append(pageLabel); sr.append("\" ajaxSelectUrl=\""); sr.append(ajaxSelectUrl); sr.append("\" selectUrl=\""); sr.append(selectUrl); sr.append("\" ajaxSelectSizeUrl=\""); sr.append(ajaxSelectSizeUrl); sr.append("\" selectSizeUrl=\""); sr.append(selectSizeUrl); sr.append("\" commonDisplaying=\""); sr.append(commonDisplaying); sr.append("\" paginateNextStyle=\""); sr.append(paginateNextStyle); sr.append("\" ajaxNextUrl=\""); sr.append(ajaxNextUrl); sr.append("\" nextUrl=\""); sr.append(nextUrl); sr.append("\" paginateNextLabel=\""); sr.append(paginateNextLabel); sr.append("\" paginateLastStyle=\""); sr.append(paginateLastStyle); sr.append("\" ajaxLastUrl=\""); sr.append(ajaxLastUrl); sr.append("\" lastUrl=\""); sr.append(lastUrl); sr.append("\" paginateLastLabel=\""); sr.append(paginateLastLabel); sr.append("\" paginateViewSizeLabel=\""); sr.append(paginateViewSizeLabel); sr.append("\" />"); executeMacro(writer, sr.toString()); } MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response);  MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response,
                             FtlWriter ftlWriter); @Deprecated  MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response); }
MacroFormRenderer implements FormStringRenderer { public void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm) { boolean ajaxEnabled = false; List<ModelForm.UpdateArea> updateAreas = modelForm.getOnPaginateUpdateAreas(); String targetService = modelForm.getPaginateTarget(context); if (this.javaScriptEnabled) { if (UtilValidate.isNotEmpty(updateAreas)) { ajaxEnabled = true; } } if (targetService == null) { targetService = "${targetService}"; } if (UtilValidate.isEmpty(targetService) && updateAreas == null) { Debug.logWarning("Cannot paginate because TargetService is empty for the form: " + modelForm.getName(), MODULE); return; } int paginatorNumber = WidgetWorker.getPaginatorNumber(context); String viewIndexParam = modelForm.getMultiPaginateIndexField(context); String viewSizeParam = modelForm.getMultiPaginateSizeField(context); int viewIndex = Paginator.getViewIndex(modelForm, context); int viewSize = Paginator.getViewSize(modelForm, context); int listSize = Paginator.getListSize(context); int lowIndex = Paginator.getLowIndex(context); int highIndex = Paginator.getHighIndex(context); int actualPageSize = Paginator.getActualPageSize(context); Map<String, String> uiLabelMap = UtilGenerics.cast(context.get("uiLabelMap")); String pageLabel = ""; String commonDisplaying = ""; if (uiLabelMap == null) { Debug.logWarning("Could not find uiLabelMap in context", MODULE); } else { pageLabel = uiLabelMap.get("CommonPage"); Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", lowIndex + 1, "highCount", lowIndex + actualPageSize, "total", listSize); commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale")); } if (("viewIndex" + "_" + paginatorNumber).equals(viewIndexParam)) { viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber; } if (("viewSize" + "_" + paginatorNumber).equals(viewSizeParam)) { viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber; } String str = (String) context.get("_QBESTRING_"); String tokenValue = CsrfUtil.generateTokenForNonAjax(request, targetService); str = CsrfUtil.addOrUpdateTokenInQueryString(str, tokenValue); String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber); Set<String> paramNames = new HashSet<>(); paramNames.add(viewIndexParam); paramNames.add(viewSizeParam); queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames); String anchor = ""; String paginateAnchor = modelForm.getPaginateTargetAnchor(); if (UtilValidate.isNotEmpty(paginateAnchor)) { anchor = "#" + paginateAnchor; } String urlPath = UtilHttp.removeQueryStringFromTarget(targetService); String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService); String prepLinkSizeText; if (UtilValidate.isNotEmpty(queryString)) { queryString = UtilHttp.encodeAmpersands(queryString); } if (prepLinkText.indexOf('?') < 0) { prepLinkText += "?"; } else if (!prepLinkText.endsWith("?")) { prepLinkText += "&amp;"; } if (UtilValidate.isNotEmpty(queryString) && !"null".equals(queryString)) { prepLinkText += queryString + "&amp;"; } prepLinkSizeText = prepLinkText + viewSizeParam + "='+this.value+'" + "&amp;" + viewIndexParam + "=0"; prepLinkText += viewSizeParam + "=" + viewSize + "&amp;" + viewIndexParam + "="; if (ajaxEnabled) { prepLinkText = prepLinkText.replace("?", ""); prepLinkText = prepLinkText.replace("&amp;", "&"); } String linkText; String paginateStyle = modelForm.getPaginateStyle(); String paginateFirstStyle = modelForm.getPaginateFirstStyle(); String paginateFirstLabel = modelForm.getPaginateFirstLabel(context); String firstUrl = ""; String ajaxFirstUrl = ""; String paginatePreviousStyle = modelForm.getPaginatePreviousStyle(); String paginatePreviousLabel = modelForm.getPaginatePreviousLabel(context); String previousUrl = ""; String ajaxPreviousUrl = ""; String selectUrl = ""; String ajaxSelectUrl = ""; String paginateViewSizeLabel = modelForm.getPaginateViewSizeLabel(context); String selectSizeUrl = ""; String ajaxSelectSizeUrl = ""; String paginateNextStyle = modelForm.getPaginateNextStyle(); String paginateNextLabel = modelForm.getPaginateNextLabel(context); String nextUrl = ""; String ajaxNextUrl = ""; String paginateLastStyle = modelForm.getPaginateLastStyle(); String paginateLastLabel = modelForm.getPaginateLastLabel(context); String lastUrl = ""; String ajaxLastUrl = ""; if (viewIndex > 0) { if (ajaxEnabled) { ajaxFirstUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + 0 + anchor, context); } else { linkText = prepLinkText + 0 + anchor; firstUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (viewIndex > 0) { if (ajaxEnabled) { ajaxPreviousUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex - 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex - 1) + anchor; previousUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + "' + this.value + '", context); } else { linkText = prepLinkText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { if (ajaxEnabled) { ajaxNextUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex + 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex + 1) + anchor; nextUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize); if (ajaxEnabled) { ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + lastIndex + anchor, context); } else { linkText = prepLinkText + lastIndex + anchor; lastUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectSizeUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkSizeText + anchor, context); } else { linkText = prepLinkSizeText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectSizeUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } StringWriter sr = new StringWriter(); sr.append("<@renderNextPrev "); sr.append(" paginateStyle=\""); sr.append(paginateStyle); sr.append("\" paginateFirstStyle=\""); sr.append(paginateFirstStyle); sr.append("\" viewIndex="); sr.append(Integer.toString(viewIndex)); sr.append(" highIndex="); sr.append(Integer.toString(highIndex)); sr.append(" listSize="); sr.append(Integer.toString(listSize)); sr.append(" viewSize="); sr.append(Integer.toString(viewSize)); sr.append(" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" javaScriptEnabled="); sr.append(Boolean.toString(javaScriptEnabled)); sr.append(" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" firstUrl=\""); sr.append(firstUrl); sr.append("\" paginateFirstLabel=\""); sr.append(paginateFirstLabel); sr.append("\" paginatePreviousStyle=\""); sr.append(paginatePreviousStyle); sr.append("\" ajaxPreviousUrl=\""); sr.append(ajaxPreviousUrl); sr.append("\" previousUrl=\""); sr.append(previousUrl); sr.append("\" paginatePreviousLabel=\""); sr.append(paginatePreviousLabel); sr.append("\" pageLabel=\""); sr.append(pageLabel); sr.append("\" ajaxSelectUrl=\""); sr.append(ajaxSelectUrl); sr.append("\" selectUrl=\""); sr.append(selectUrl); sr.append("\" ajaxSelectSizeUrl=\""); sr.append(ajaxSelectSizeUrl); sr.append("\" selectSizeUrl=\""); sr.append(selectSizeUrl); sr.append("\" commonDisplaying=\""); sr.append(commonDisplaying); sr.append("\" paginateNextStyle=\""); sr.append(paginateNextStyle); sr.append("\" ajaxNextUrl=\""); sr.append(ajaxNextUrl); sr.append("\" nextUrl=\""); sr.append(nextUrl); sr.append("\" paginateNextLabel=\""); sr.append(paginateNextLabel); sr.append("\" paginateLastStyle=\""); sr.append(paginateLastStyle); sr.append("\" ajaxLastUrl=\""); sr.append(ajaxLastUrl); sr.append("\" lastUrl=\""); sr.append(lastUrl); sr.append("\" paginateLastLabel=\""); sr.append(paginateLastLabel); sr.append("\" paginateViewSizeLabel=\""); sr.append(paginateViewSizeLabel); sr.append("\" />"); executeMacro(writer, sr.toString()); } MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response);  MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response,
                             FtlWriter ftlWriter); @Deprecated  MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response); static String getAjaxParamsFromTarget(String target); boolean getRenderPagination(); void setRenderPagination(boolean renderPagination); void renderLabel(Appendable writer, Map<String, Object> context, ModelScreenWidget.Label label); @Override void renderDisplayField(Appendable writer, Map<String, Object> context, DisplayField displayField); @Override void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField); @Override void renderMenuField(Appendable writer, Map<String, Object> context, MenuField menuField); @Override void renderTextField(Appendable writer, Map<String, Object> context, TextField textField); @Override void renderTextareaField(Appendable writer, Map<String, Object> context, TextareaField textareaField); @Override void renderDateTimeField(Appendable writer, Map<String, Object> context, DateTimeField dateTimeField); @Override void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField); @Override void renderCheckField(Appendable writer, Map<String, Object> context, CheckField checkField); @Override void renderRadioField(Appendable writer, Map<String, Object> context, RadioField radioField); @Override void renderSubmitField(Appendable writer, Map<String, Object> context, SubmitField submitField); @Override void renderResetField(Appendable writer, Map<String, Object> context, ResetField resetField); @Override void renderHiddenField(Appendable writer, Map<String, Object> context, HiddenField hiddenField); @Override void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String value); @Override void renderIgnoredField(Appendable writer, Map<String, Object> context, IgnoredField ignoredField); @Override void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField,
                                              int positionSpan); @Override void renderFormatHeaderRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField); @Override void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm,
                                                            ModelFormField modelFormField, boolean isLast); @Override void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField,
                                            int positionSpan); @Override void renderFormatItemRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField); @Override void renderFormatItemRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatSingleWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatSingleWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowTitleCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowTitleCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowSpacerCell(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowWidgetCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions,
                                                   int positionSpan, Integer nextPositionInRow); @Override void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions,
                                                    int positionSpan, Integer nextPositionInRow); @Override void renderFormatEmptySpace(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField); @Override void renderRangeFindField(Appendable writer, Map<String, Object> context, RangeFindField rangeFindField); @Override void renderDateFindField(Appendable writer, Map<String, Object> context, DateFindField dateFindField); @Override void renderLookupField(Appendable writer, Map<String, Object> context, LookupField lookupField); void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFileField(Appendable writer, Map<String, Object> context, FileField textField); @Override void renderPasswordField(Appendable writer, Map<String, Object> context, PasswordField passwordField); @Override void renderImageField(Appendable writer, Map<String, Object> context, ImageField imageField); @Override void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup); @Override void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup); @Override void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner); void renderBeginningBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget); void renderEndingBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget); void renderSortField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText); String createAjaxParamsFromUpdateAreas(List<ModelForm.UpdateArea> updateAreas, String extraParams, Map<String, ? extends Object> context); void appendTooltip(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); void makeHyperlinkString(Appendable writer, ModelFormField.SubHyperlink subHyperlink, Map<String, Object> context); void addAsterisks(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); void appendContentUrl(Appendable writer, String location); void makeHyperlinkByType(Appendable writer, String linkType, String linkStyle, String targetType, String target, Map<String,
            String> parameterMap, String description, String targetWindow, String confirmation, ModelFormField modelFormField,
            HttpServletRequest request, HttpServletResponse response, Map<String, Object> context); void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, Map<String, String> parameterMap,
                                    String description, String confirmation, ModelFormField modelFormField, HttpServletRequest request,
                                    HttpServletResponse response, Map<String, Object> context, String targetWindow); void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation, ModelFormField modelFormField,
                                         HttpServletRequest request, HttpServletResponse response, Map<String, Object> context); @Override void renderContainerFindField(Appendable writer, Map<String, Object> context, ContainerField containerField); }
MacroFormRenderer implements FormStringRenderer { public void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm) { boolean ajaxEnabled = false; List<ModelForm.UpdateArea> updateAreas = modelForm.getOnPaginateUpdateAreas(); String targetService = modelForm.getPaginateTarget(context); if (this.javaScriptEnabled) { if (UtilValidate.isNotEmpty(updateAreas)) { ajaxEnabled = true; } } if (targetService == null) { targetService = "${targetService}"; } if (UtilValidate.isEmpty(targetService) && updateAreas == null) { Debug.logWarning("Cannot paginate because TargetService is empty for the form: " + modelForm.getName(), MODULE); return; } int paginatorNumber = WidgetWorker.getPaginatorNumber(context); String viewIndexParam = modelForm.getMultiPaginateIndexField(context); String viewSizeParam = modelForm.getMultiPaginateSizeField(context); int viewIndex = Paginator.getViewIndex(modelForm, context); int viewSize = Paginator.getViewSize(modelForm, context); int listSize = Paginator.getListSize(context); int lowIndex = Paginator.getLowIndex(context); int highIndex = Paginator.getHighIndex(context); int actualPageSize = Paginator.getActualPageSize(context); Map<String, String> uiLabelMap = UtilGenerics.cast(context.get("uiLabelMap")); String pageLabel = ""; String commonDisplaying = ""; if (uiLabelMap == null) { Debug.logWarning("Could not find uiLabelMap in context", MODULE); } else { pageLabel = uiLabelMap.get("CommonPage"); Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", lowIndex + 1, "highCount", lowIndex + actualPageSize, "total", listSize); commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale")); } if (("viewIndex" + "_" + paginatorNumber).equals(viewIndexParam)) { viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber; } if (("viewSize" + "_" + paginatorNumber).equals(viewSizeParam)) { viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber; } String str = (String) context.get("_QBESTRING_"); String tokenValue = CsrfUtil.generateTokenForNonAjax(request, targetService); str = CsrfUtil.addOrUpdateTokenInQueryString(str, tokenValue); String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber); Set<String> paramNames = new HashSet<>(); paramNames.add(viewIndexParam); paramNames.add(viewSizeParam); queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames); String anchor = ""; String paginateAnchor = modelForm.getPaginateTargetAnchor(); if (UtilValidate.isNotEmpty(paginateAnchor)) { anchor = "#" + paginateAnchor; } String urlPath = UtilHttp.removeQueryStringFromTarget(targetService); String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService); String prepLinkSizeText; if (UtilValidate.isNotEmpty(queryString)) { queryString = UtilHttp.encodeAmpersands(queryString); } if (prepLinkText.indexOf('?') < 0) { prepLinkText += "?"; } else if (!prepLinkText.endsWith("?")) { prepLinkText += "&amp;"; } if (UtilValidate.isNotEmpty(queryString) && !"null".equals(queryString)) { prepLinkText += queryString + "&amp;"; } prepLinkSizeText = prepLinkText + viewSizeParam + "='+this.value+'" + "&amp;" + viewIndexParam + "=0"; prepLinkText += viewSizeParam + "=" + viewSize + "&amp;" + viewIndexParam + "="; if (ajaxEnabled) { prepLinkText = prepLinkText.replace("?", ""); prepLinkText = prepLinkText.replace("&amp;", "&"); } String linkText; String paginateStyle = modelForm.getPaginateStyle(); String paginateFirstStyle = modelForm.getPaginateFirstStyle(); String paginateFirstLabel = modelForm.getPaginateFirstLabel(context); String firstUrl = ""; String ajaxFirstUrl = ""; String paginatePreviousStyle = modelForm.getPaginatePreviousStyle(); String paginatePreviousLabel = modelForm.getPaginatePreviousLabel(context); String previousUrl = ""; String ajaxPreviousUrl = ""; String selectUrl = ""; String ajaxSelectUrl = ""; String paginateViewSizeLabel = modelForm.getPaginateViewSizeLabel(context); String selectSizeUrl = ""; String ajaxSelectSizeUrl = ""; String paginateNextStyle = modelForm.getPaginateNextStyle(); String paginateNextLabel = modelForm.getPaginateNextLabel(context); String nextUrl = ""; String ajaxNextUrl = ""; String paginateLastStyle = modelForm.getPaginateLastStyle(); String paginateLastLabel = modelForm.getPaginateLastLabel(context); String lastUrl = ""; String ajaxLastUrl = ""; if (viewIndex > 0) { if (ajaxEnabled) { ajaxFirstUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + 0 + anchor, context); } else { linkText = prepLinkText + 0 + anchor; firstUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (viewIndex > 0) { if (ajaxEnabled) { ajaxPreviousUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex - 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex - 1) + anchor; previousUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + "' + this.value + '", context); } else { linkText = prepLinkText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { if (ajaxEnabled) { ajaxNextUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (viewIndex + 1) + anchor, context); } else { linkText = prepLinkText + (viewIndex + 1) + anchor; nextUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (highIndex < listSize) { int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize); if (ajaxEnabled) { ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + lastIndex + anchor, context); } else { linkText = prepLinkText + lastIndex + anchor; lastUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } if (listSize > 0 && this.javaScriptEnabled) { if (ajaxEnabled) { ajaxSelectSizeUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkSizeText + anchor, context); } else { linkText = prepLinkSizeText; if (linkText.startsWith("/")) { linkText = linkText.substring(1); } selectSizeUrl = rh.makeLink(this.request, this.response, urlPath + linkText); } } StringWriter sr = new StringWriter(); sr.append("<@renderNextPrev "); sr.append(" paginateStyle=\""); sr.append(paginateStyle); sr.append("\" paginateFirstStyle=\""); sr.append(paginateFirstStyle); sr.append("\" viewIndex="); sr.append(Integer.toString(viewIndex)); sr.append(" highIndex="); sr.append(Integer.toString(highIndex)); sr.append(" listSize="); sr.append(Integer.toString(listSize)); sr.append(" viewSize="); sr.append(Integer.toString(viewSize)); sr.append(" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" javaScriptEnabled="); sr.append(Boolean.toString(javaScriptEnabled)); sr.append(" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" ajaxFirstUrl=\""); sr.append(ajaxFirstUrl); sr.append("\" firstUrl=\""); sr.append(firstUrl); sr.append("\" paginateFirstLabel=\""); sr.append(paginateFirstLabel); sr.append("\" paginatePreviousStyle=\""); sr.append(paginatePreviousStyle); sr.append("\" ajaxPreviousUrl=\""); sr.append(ajaxPreviousUrl); sr.append("\" previousUrl=\""); sr.append(previousUrl); sr.append("\" paginatePreviousLabel=\""); sr.append(paginatePreviousLabel); sr.append("\" pageLabel=\""); sr.append(pageLabel); sr.append("\" ajaxSelectUrl=\""); sr.append(ajaxSelectUrl); sr.append("\" selectUrl=\""); sr.append(selectUrl); sr.append("\" ajaxSelectSizeUrl=\""); sr.append(ajaxSelectSizeUrl); sr.append("\" selectSizeUrl=\""); sr.append(selectSizeUrl); sr.append("\" commonDisplaying=\""); sr.append(commonDisplaying); sr.append("\" paginateNextStyle=\""); sr.append(paginateNextStyle); sr.append("\" ajaxNextUrl=\""); sr.append(ajaxNextUrl); sr.append("\" nextUrl=\""); sr.append(nextUrl); sr.append("\" paginateNextLabel=\""); sr.append(paginateNextLabel); sr.append("\" paginateLastStyle=\""); sr.append(paginateLastStyle); sr.append("\" ajaxLastUrl=\""); sr.append(ajaxLastUrl); sr.append("\" lastUrl=\""); sr.append(lastUrl); sr.append("\" paginateLastLabel=\""); sr.append(paginateLastLabel); sr.append("\" paginateViewSizeLabel=\""); sr.append(paginateViewSizeLabel); sr.append("\" />"); executeMacro(writer, sr.toString()); } MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response);  MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response,
                             FtlWriter ftlWriter); @Deprecated  MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response); static String getAjaxParamsFromTarget(String target); boolean getRenderPagination(); void setRenderPagination(boolean renderPagination); void renderLabel(Appendable writer, Map<String, Object> context, ModelScreenWidget.Label label); @Override void renderDisplayField(Appendable writer, Map<String, Object> context, DisplayField displayField); @Override void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField); @Override void renderMenuField(Appendable writer, Map<String, Object> context, MenuField menuField); @Override void renderTextField(Appendable writer, Map<String, Object> context, TextField textField); @Override void renderTextareaField(Appendable writer, Map<String, Object> context, TextareaField textareaField); @Override void renderDateTimeField(Appendable writer, Map<String, Object> context, DateTimeField dateTimeField); @Override void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField); @Override void renderCheckField(Appendable writer, Map<String, Object> context, CheckField checkField); @Override void renderRadioField(Appendable writer, Map<String, Object> context, RadioField radioField); @Override void renderSubmitField(Appendable writer, Map<String, Object> context, SubmitField submitField); @Override void renderResetField(Appendable writer, Map<String, Object> context, ResetField resetField); @Override void renderHiddenField(Appendable writer, Map<String, Object> context, HiddenField hiddenField); @Override void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String value); @Override void renderIgnoredField(Appendable writer, Map<String, Object> context, IgnoredField ignoredField); @Override void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField,
                                              int positionSpan); @Override void renderFormatHeaderRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField); @Override void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm,
                                                            ModelFormField modelFormField, boolean isLast); @Override void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField,
                                            int positionSpan); @Override void renderFormatItemRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField); @Override void renderFormatItemRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatSingleWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatSingleWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowTitleCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowTitleCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowSpacerCell(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowWidgetCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions,
                                                   int positionSpan, Integer nextPositionInRow); @Override void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions,
                                                    int positionSpan, Integer nextPositionInRow); @Override void renderFormatEmptySpace(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField); @Override void renderRangeFindField(Appendable writer, Map<String, Object> context, RangeFindField rangeFindField); @Override void renderDateFindField(Appendable writer, Map<String, Object> context, DateFindField dateFindField); @Override void renderLookupField(Appendable writer, Map<String, Object> context, LookupField lookupField); void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFileField(Appendable writer, Map<String, Object> context, FileField textField); @Override void renderPasswordField(Appendable writer, Map<String, Object> context, PasswordField passwordField); @Override void renderImageField(Appendable writer, Map<String, Object> context, ImageField imageField); @Override void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup); @Override void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup); @Override void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner); void renderBeginningBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget); void renderEndingBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget); void renderSortField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText); String createAjaxParamsFromUpdateAreas(List<ModelForm.UpdateArea> updateAreas, String extraParams, Map<String, ? extends Object> context); void appendTooltip(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); void makeHyperlinkString(Appendable writer, ModelFormField.SubHyperlink subHyperlink, Map<String, Object> context); void addAsterisks(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); void appendContentUrl(Appendable writer, String location); void makeHyperlinkByType(Appendable writer, String linkType, String linkStyle, String targetType, String target, Map<String,
            String> parameterMap, String description, String targetWindow, String confirmation, ModelFormField modelFormField,
            HttpServletRequest request, HttpServletResponse response, Map<String, Object> context); void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, Map<String, String> parameterMap,
                                    String description, String confirmation, ModelFormField modelFormField, HttpServletRequest request,
                                    HttpServletResponse response, Map<String, Object> context, String targetWindow); void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation, ModelFormField modelFormField,
                                         HttpServletRequest request, HttpServletResponse response, Map<String, Object> context); @Override void renderContainerFindField(Appendable writer, Map<String, Object> context, ContainerField containerField);  }