# HG changeset patch # User Ingo Weinzierl # Date 1328704060 0 # Node ID a4da53328693de70ca7ce461d73964ef705f09b8 # Parent fe59df5c85cce619931a5c2a7e17f451c4fdc99c #482 Display i18n messages for validation errors in range panel. flys-client/trunk@3967 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r fe59df5c85cc -r a4da53328693 flys-client/ChangeLog --- 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 + + 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 Partial fix flys/issue471. diff -r fe59df5c85cc -r a4da53328693 flys-client/src/main/java/de/intevation/flys/client/client/ui/IntegerRangePanel.java --- 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; } diff -r fe59df5c85cc -r a4da53328693 flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java --- 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 validate() { + List errors = new ArrayList(); + + 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 validate() { - List errors = new ArrayList(); - - if (!lowerForm.validate()) { - errors.add("LOWER ERRORS"); - } - - if (!upperForm.validate()) { - errors.add("UPPER ERRORS"); - } - - return errors; + protected Data[] getData() { + return new Data[0]; }