|
Author: erwan
Date: Thu Nov 29 14:58:28 2012 New Revision: 1415193 URL: http://svn.apache.org/viewvc?rev=1415193&view=rev Log: when using multiple values for one field in a search form like status field, the generated parameters for the sortable header field in the result list are separated by a comma. This is not workable if the call is done by javascript. This modification replace the comma by an apostrophe in the generated parameters and in the javascript method an apostrophe is replace by a comma before processing parameters. Modified: ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/StringUtil.java ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Modified: ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java?rev=1415193&r1=1415192&r2=1415193&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java Thu Nov 29 14:58:28 2012 @@ -146,7 +146,8 @@ public class CollectionConverters implem @Override public List<String> convert(String obj) throws ConversionException { - if (obj.startsWith("[") && obj.endsWith("]")) { + if (obj.startsWith("[") && obj.endsWith("]") + || (obj.startsWith("{") && obj.endsWith("}"))) { return StringUtil.toList(obj); } else { return super.convert(obj); Modified: ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/StringUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1415193&r1=1415192&r2=1415193&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/StringUtil.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/StringUtil.java Thu Nov 29 14:58:28 2012 @@ -396,7 +396,8 @@ public class StringUtil { */ public static List<String> toList(String s) { List<String> newList = FastList.newInstance(); - if (s.startsWith("[") && s.endsWith("]")) { + if (s.startsWith("[") && s.endsWith("]") + || (s.startsWith("{") && s.endsWith("}"))) { s = s.substring(1, s.length() - 1); String[] entries = s.split("\\,\\s"); for (String entry: entries) { Modified: ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js?rev=1415193&r1=1415192&r2=1415193&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js (original) +++ ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js Thu Nov 29 14:58:28 2012 @@ -240,6 +240,7 @@ function confirmActionFormLink(msg, form */ function ajaxUpdateArea(areaId, target, targetParams) { + targetParams = decodeCommaParams(targetParams); waitSpinnerShow(); jQuery.ajax({ url: target, @@ -269,6 +270,7 @@ function ajaxUpdateAreas(areaCsvString) // not nice but works targetParams = targetParams.replace('#',''); targetParams = targetParams.replace('?',''); + targetParams = decodeCommaParams(targetParams); /*#Bam# portletWidget wait-spinner working*/ var UPDATE_OP = {}; UPDATE_OP.areaId = areaId; @@ -313,6 +315,7 @@ function ajaxUpdateAreas(areaCsvString) * @param interval The update interval, in seconds. */ function ajaxUpdateAreaPeriodic(areaId, target, targetParams, interval) { + targetParams = decodeCommaParams(targetParams); jQuery.fjTimer({ interval: interval, repeat: true, @@ -339,6 +342,8 @@ function ajaxUpdateAreaPeriodic(areaId, * form of: areaId, target, target parameters [, areaId, target, target parameters...]. */ function ajaxSubmitRequestUpdateAreas(target, targetParams, areaCsvString) { + targetParams = decodeCommaParams(targetParams); + areaCsvString = decodeCommaParams(areaCsvString); updateFunction = function(transport) { ajaxUpdateAreas(areaCsvString); } @@ -377,6 +382,7 @@ function ajaxSubmitFormUpdateAreas(form, hideErrorContainer = function() { jQuery('#content-messages').removeClass('errorMessage').fadeIn('fast'); } + areaCsvString = decodeCommaParams(areaCsvString); updateFunction = function(data) { /*#Bam# portletWidget*/ if ((data._ERROR_MESSAGE_LIST_ != undefined || data._ERROR_MESSAGE_ != undefined) @@ -793,6 +799,14 @@ function replaceQueryParam(queryString, return result; } +//Function to replace ` with , (comma are encoded in parameters on server side to avoid errors in ajax script) +function decodeCommaParams (txt) { + if (txt != null && typeof txt == 'string') { + txt = txt.replace(new RegExp('`', 'g'),','); + } + return txt; +} + function submitFormDisableSubmits(form) { for (var i=0;i<form.length;i++) { var formel = form.elements[i]; Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1415193&r1=1415192&r2=1415193&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Thu Nov 29 14:58:28 2012 @@ -2973,6 +2973,10 @@ public class MacroFormRenderer implement } String ajaxUrl = ""; boolean firstLoop = true; + //Replace , with ` in parameters to avoid errors in ajax script + if (UtilValidate.isNotEmpty(extraParams) && extraParams.contains("%2C")) { + extraParams = extraParams.replaceAll("%2C","%60"); + } for (ModelForm.UpdateArea updateArea : updateAreas) { if (firstLoop) { firstLoop = false; |
| Free forum by Nabble | Edit this page |
