Mercurial > dive4elements > river
changeset 4627:d5821c6f0ab0
Fixed validation in parameter matrix panel. Single selections are allowed now.
Avoid adding duplicates of user selection in parameter matrix.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 03 Dec 2012 17:25:49 +0100 |
parents | 5b551e3a58d5 |
children | 03ab907b6f5d |
files | flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java |
diffstat | 2 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java Mon Dec 03 17:10:08 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java Mon Dec 03 17:25:49 2012 +0100 @@ -263,16 +263,23 @@ } ListGridRecord[] records = listGrid.getRecords(); - for (ListGridRecord record: records) { + Map<String, List<String>> result = new HashMap<String, List<String>>(); + for (ListGridRecord record : records) { for (int i = 0, n = columnNames.size(); i < n; i++) { String columnName = columnNames.get(i); - List<String> chosenItems = selected.get(columnName); if (Boolean.valueOf(record.getAttribute(columnName)) == true) { - chosenItems.add(record.getAttribute(columnName + "-value")); + if (result.containsKey(columnName)) { + result.get(columnName).add(record.getAttribute(columnName + "-value")); + } + else { + List<String> items = new ArrayList<String>(); + items.add(record.getAttribute(columnName + "-value")); + result.put(columnName, items); + } } } } - return selected; + return result; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java Mon Dec 03 17:10:08 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java Mon Dec 03 17:25:49 2012 +0100 @@ -176,11 +176,20 @@ GWT.log ("validation. validation. validation. "); List<String> errors = new ArrayList<String>(); // Early stop on one (only) error. + boolean ok = false; for (Map.Entry<String, List<String>> entry : matrix.getSelection().entrySet()) { + /* single entries are allowed!! if (entry.getValue() == null || entry.getValue().size() == 0) { errors.add(MESSAGES.error_values_needed()); return errors; } + */ + if (entry.getValue() != null && entry.getValue().size() > 0) { + ok = true; + } + } + if (!ok) { + errors.add(MESSAGES.error_values_needed()); } return errors; }