details: https://code.openbravo.com/erp/devel/pi/rev/81994596bc51 changeset: 33413:81994596bc51 user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Thu Feb 08 18:10:27 2018 +0100 summary: fixes bug 37857: Wrong FIC request after selecting hundreds of records
The MULTIPLE_ROW_IDS parameter contains the ids of the selected records that are sent to the FIC. They are used to check if there exists attachments within the selection and in that case enable the attachment button of the toolbar or display the number of attachments of the current record in case we are in form view. This information was being sent as part of the request URL in the HTTP header which in case of having hundreds of records, the maximum size allowed for the request URL was being exceeded. To fix this problem, now the MULTIPLE_ROW_IDS parameter is sent within the body of the FIC request. diffstat: modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java | 12 ++++++--- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js | 10 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diffs (105 lines): diff -r 967f7b6068ee -r 81994596bc51 modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java --- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java Thu Feb 08 17:46:57 2018 +0100 +++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java Thu Feb 08 18:10:27 2018 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2010-2017 Openbravo SLU + * All portions are Copyright (C) 2010-2018 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -22,6 +22,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -134,7 +135,7 @@ // The ID of the record. Only relevant on EDIT, CHANGE and SETSESSION modes rowId = readParameter(parameters, "ROW_ID"); // The IDs of the selected records in case more than one - String multipleRowIds[] = (String[]) parameters.get("MULTIPLE_ROW_IDS"); + List<String> multipleRowIds = null; // The column changed by the user. Only relevant on CHANGE mode String changedColumn = readParameter(parameters, "CHANGED_COLUMN"); Tab tab = getTab(tabId); @@ -184,6 +185,9 @@ if (jsContent.has("_gridVisibleProperties")) { gridVisibleProperties = convertJSONArray(jsContent.getJSONArray("_gridVisibleProperties")); } + if (jsContent.has("MULTIPLE_ROW_IDS")) { + multipleRowIds = convertJSONArray(jsContent.getJSONArray("MULTIPLE_ROW_IDS")); + } List<String> overwrittenAuxiliaryInputs = new ArrayList<String>(); // The provided overwrittenAuxiliaryInputs only have to be persisted when calling the FIC in @@ -298,7 +302,7 @@ if (multipleRowIds != null) { attachmentCount = computeAttachmentCount(tab, multipleRowIds, true); } else { - attachmentCount = computeAttachmentCount(tab, new String[] { rowId }, false); + attachmentCount = computeAttachmentCount(tab, Arrays.asList(rowId), false); } // Notes information @@ -397,7 +401,7 @@ * flag to not return the actual count just 1 or 0 * @return count of attachment found for the given records. */ - private int computeAttachmentCount(Tab tab, String[] recordIds, boolean doExists) { + private int computeAttachmentCount(Tab tab, List<String> recordIds, boolean doExists) { String tableId = tab.getTable().getId(); OBCriteria<Attachment> attachmentFiles = OBDao.getFilteredCriteria(Attachment.class, Restrictions.eq("table.id", tableId), Restrictions.in("record", recordIds)); diff -r 967f7b6068ee -r 81994596bc51 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js Thu Feb 08 17:46:57 2018 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js Thu Feb 08 18:10:27 2018 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2010-2017 Openbravo SLU + * All portions are Copyright (C) 2010-2018 Openbravo SLU * All Rights Reserved. * Contributor(s): Sreedhar Sirigiri (TDS), Mallikarjun M (TDS) ************************************************************************ @@ -1342,13 +1342,13 @@ ROW_ID: currentValues.id }; multipleSelectedRowIds = []; + allProperties = currentContext.getContextInfo(false, true, false, true); if (selectedRecords.size() > 1) { for (i = 0; i < selectedRecords.size(); i++) { multipleSelectedRowIds[i] = selectedRecords[i].id; } - requestParams.MULTIPLE_ROW_IDS = multipleSelectedRowIds; + allProperties.MULTIPLE_ROW_IDS = multipleSelectedRowIds; } - allProperties = currentContext.getContextInfo(false, true, false, true); if (currentContext.viewGrid && currentContext.viewGrid.fields) { len = currentContext.viewGrid.fields.length; for (i = 0; i < len; i++) { @@ -1374,6 +1374,7 @@ TAB_ID: this.view.tabId }; multipleSelectedRowIds = []; + allProperties = this.view.getContextInfo(false, true, false, true); if (selectedRecords.size() >= 1) { for (i = 0; i < selectedRecords.size(); i++) { if (i === 0) { @@ -1382,10 +1383,9 @@ multipleSelectedRowIds[i] = selectedRecords[i].id; } if (selectedRecords.size() > 1) { - requestParams.MULTIPLE_ROW_IDS = multipleSelectedRowIds; + allProperties.MULTIPLE_ROW_IDS = multipleSelectedRowIds; } } - allProperties = this.view.getContextInfo(false, true, false, true); OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent', allProperties, requestParams, function (response, data, request) { var attachmentExists = data.attachmentExists, auxInputs = data.auxiliaryInputValues, ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits