Mercurial > dive4elements > river
changeset 1606:a4da53328693
#482 Display i18n messages for validation errors in range panel.
flys-client/trunk@3967 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 08 Feb 2012 12:27:40 +0000 |
parents | fe59df5c85cc |
children | 64e3d4b024b1 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/IntegerRangePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java |
diffstat | 3 files changed, 61 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Feb 08 10:45:46 2012 +0000 +++ b/flys-client/ChangeLog Wed Feb 08 12:27:40 2012 +0000 @@ -1,3 +1,15 @@ +2012-02-08 Ingo Weinzierl <ingo@intevation.de> + + flys/issue482 (i18n: UPPER ERROS bei Historischen Abflusskurven) + + * src/main/java/de/intevation/flys/client/client/ui/RangePanel.java: + Defined new abstract methods to determine the max lower and upper + values. Implemented the validate() method which now shows i18n error + messages. + + * src/main/java/de/intevation/flys/client/client/ui/IntegerRangePanel.java: + Implemented the methods to determine the max lower and upper values. + 2012-02-08 Felix Wolfsteller <felix.wolfsteller@intevation.de> Partial fix flys/issue471.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/IntegerRangePanel.java Wed Feb 08 10:45:46 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/IntegerRangePanel.java Wed Feb 08 12:27:40 2012 +0000 @@ -64,6 +64,18 @@ } + @Override + public Object getMaxLower() { + return maxLower; + } + + + @Override + public Object getMaxUpper() { + return maxUpper; + } + + public Integer getLowerAsInt() { String raw = getLower(); @@ -97,8 +109,8 @@ protected Validator newRangeValidator() { - Integer maxLower = getMaxLower(); - Integer maxUpper = getMaxUpper(); + Integer maxLower = getMaxLowerAsInt(); + Integer maxUpper = getMaxUpperAsInt(); if (maxLower != null && maxUpper != null) { IntegerRangeValidator validator = new IntegerRangeValidator(); @@ -112,7 +124,7 @@ } - public Integer getMaxLower() { + public Integer getMaxLowerAsInt() { return maxLower; } @@ -128,7 +140,7 @@ } - public Integer getMaxUpper() { + public Integer getMaxUpperAsInt() { return maxUpper; }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java Wed Feb 08 10:45:46 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java Wed Feb 08 12:27:40 2012 +0000 @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.List; +import com.google.gwt.core.client.GWT; + import com.smartgwt.client.types.Alignment; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; @@ -13,6 +15,7 @@ import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; @@ -30,12 +33,20 @@ public static final String FIELD_UPPER = "field_upper"; + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + protected DynamicForm lowerForm; protected DynamicForm upperForm; protected String dataName; + public abstract Object getMaxLower(); + + public abstract Object getMaxUpper(); + + + @Override public Canvas create(DataList data) { setDataName(data); @@ -75,24 +86,32 @@ @Override - protected Data[] getData() { - return new Data[0]; + public List<String> validate() { + List<String> errors = new ArrayList<String>(); + + if (!lowerForm.validate()) { + String msg = MSG.error_validate_range(); + msg = msg.replace("$1", getLower()); + msg = msg.replace("$2", String.valueOf(getMaxLower())); + msg = msg.replace("$3", String.valueOf(getMaxLower())); + errors.add(msg); + } + + if (!upperForm.validate()) { + String msg = MSG.error_validate_range(); + msg = msg.replace("$1", getUpper()); + msg = msg.replace("$2", String.valueOf(getMaxLower())); + msg = msg.replace("$3", String.valueOf(getMaxUpper())); + errors.add(msg); + } + + return errors; } @Override - public List<String> validate() { - List<String> errors = new ArrayList<String>(); - - if (!lowerForm.validate()) { - errors.add("LOWER ERRORS"); - } - - if (!upperForm.validate()) { - errors.add("UPPER ERRORS"); - } - - return errors; + protected Data[] getData() { + return new Data[0]; }