comparison flys-client/src/main/java/org/dive4elements/river/client/client/utils/IntegerValidator.java @ 5834:f507086aa94b

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:31:32 +0200
parents flys-client/src/main/java/de/intevation/flys/client/client/utils/IntegerValidator.java@c21d14e48040
children 821a02bbfb4e
comparison
equal deleted inserted replaced
5833:a2bdc0f524e8 5834:f507086aa94b
1 package de.intevation.flys.client.client.utils;
2
3 import java.util.Map;
4
5 import com.google.gwt.core.client.GWT;
6
7 import com.smartgwt.client.widgets.form.fields.FormItem;
8
9 import de.intevation.flys.client.client.FLYSConstants;
10
11 /**
12 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
13 */
14 public class IntegerValidator implements Validator {
15
16 /** The interface that provides i18n messages. */
17 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
18
19 /**
20 *
21 */
22 public boolean validate(FormItem item, Map errors) {
23 boolean valid = true;
24
25 String v = item.getValue().toString();
26
27 try {
28 if (v == null) {
29 throw new NumberFormatException("empty");
30 }
31
32 int value = Integer.parseInt(v);
33
34 errors.remove(item.getFieldName());
35 }
36 catch (NumberFormatException nfe) {
37 errors.put(item.getFieldName(), MSG.wrongFormat());
38
39 item.focusInItem();
40
41 valid = false;
42 }
43 return valid;
44 }
45 }

http://dive4elements.wald.intevation.org