From 550b60b2f0f63f6d31c2bf87e0c69fc3bdc97818 Mon Sep 17 00:00:00 2001 From: Ilya Chekashkin Date: Mon, 28 Oct 2013 10:09:42 +0000 Subject: [PATCH] NPE when enter blank string into maximum results field in WebFilter #PL-3005 --- .../cuba/web/gui/components/WebFilter.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/web/src/com/haulmont/cuba/web/gui/components/WebFilter.java b/modules/web/src/com/haulmont/cuba/web/gui/components/WebFilter.java index 220173e55a..901d74edce 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/components/WebFilter.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/components/WebFilter.java @@ -433,16 +433,19 @@ public class WebFilter extends WebAbstractComponent i applyDatasourceFilter(); if (useMaxResults) { - int maxResults; - if (BooleanUtils.isTrue(maxResultsCb.getValue())) - try { - //noinspection ConstantConditions - maxResults = Datatypes.get(Integer.class).parse(maxResultsField.getValue(), userSessionSource.getLocale()); - } catch (ParseException e) { - throw new Validator.InvalidValueException(""); - } - else - maxResults = persistenceManager.getMaxFetchUI(datasource.getMetaClass().getName()); + int maxResults = 0; + if (BooleanUtils.isTrue(maxResultsCb.getValue())) { + String maxResultsFieldValue = maxResultsField.getValue(); + if (StringUtils.isNotBlank(maxResultsFieldValue)) { + try { + //noinspection ConstantConditions + maxResults = Datatypes.get(Integer.class).parse(maxResultsFieldValue, userSessionSource.getLocale()); + } catch (ParseException e) { + throw new Validator.InvalidValueException(""); + } + } else + maxResults = persistenceManager.getMaxFetchUI(datasource.getMetaClass().getName()); + } datasource.setMaxResults(maxResults); } if (datasource instanceof CollectionDatasource.SupportsPaging)