Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java @ 562:9f16ac843dda
Introduced a client side validation before new user data are sent to the server - the range/location panel already implements this validation.
flys-client/trunk@2097 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 09 Jun 2011 14:06:10 +0000 |
parents | 4a684d29404f |
children | dfbc6693247e |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java Thu Jun 09 10:57:42 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java Thu Jun 09 14:06:10 2011 +0000 @@ -5,6 +5,7 @@ import com.google.gwt.core.client.GWT; +import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.events.ClickEvent; @@ -116,9 +117,21 @@ * @param e The click event. */ public void onClick(ClickEvent e) { - Data[] data = getData(); + List<String> errors = validate(); + if (errors == null || errors.isEmpty()) { + Data[] data = getData(); + fireStepForwardEvent(new StepForwardEvent(data)); + } + else { + StringBuilder sb = new StringBuilder(); - fireStepForwardEvent(new StepForwardEvent(data)); + for (String error: errors) { + sb.append(error); + sb.append("<br>"); + } + + SC.warn(sb.toString()); + } } @@ -216,6 +229,11 @@ } + public List<String> validate() { + return new ArrayList<String>(); + } + + /** * This method needs to be implemented by concrete subclasses. It should * create a new Canvas object with a representation of <i>data</i>.