Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/utils/Validator.java @ 1507:c21d14e48040
Improved validation and property handling.
flys-client/trunk@3645 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 11 Jan 2012 10:21:22 +0000 |
parents | 02a9104c0451 |
children |
comparison
equal
deleted
inserted
replaced
1506:339f8aa641b5 | 1507:c21d14e48040 |
---|---|
1 package de.intevation.flys.client.client.utils; | 1 package de.intevation.flys.client.client.utils; |
2 | 2 |
3 import java.util.Map; | 3 import java.util.Map; |
4 | 4 |
5 import com.google.gwt.core.client.GWT; | |
6 | |
7 import com.smartgwt.client.widgets.form.DynamicForm; | |
8 import com.smartgwt.client.widgets.form.fields.FormItem; | 5 import com.smartgwt.client.widgets.form.fields.FormItem; |
9 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; | |
10 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; | |
11 | |
12 import de.intevation.flys.client.client.FLYSConstants; | |
13 | 6 |
14 /** | 7 /** |
15 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 8 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
16 * | 9 * |
17 * This validator is used for SmartGWT FormItems. | 10 * This validator is used for SmartGWT FormItems. |
18 * | |
19 * To use this validator an attribute named 'internalType' has to be set. | |
20 * Values for 'internalType': | |
21 * 'double' | |
22 * 'integer' | |
23 */ | 11 */ |
24 public class Validator implements ChangedHandler { | 12 public interface Validator { |
25 | 13 |
26 /** The interface that provides i18n messages. */ | 14 boolean validate(FormItem item, Map errors); |
27 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | |
28 | |
29 | |
30 /** | |
31 * | |
32 */ | |
33 public void onChanged(ChangedEvent e) { | |
34 FormItem item = e.getItem(); | |
35 DynamicForm form = e.getForm(); | |
36 Map errors = form.getErrors(); | |
37 String type = item.getAttribute("internalType"); | |
38 | |
39 validate(item, errors); | |
40 form.setErrors(errors, true); | |
41 } | |
42 | |
43 | |
44 protected boolean validate(FormItem item, Map errors) { | |
45 return true; | |
46 } | |
47 } | 15 } |
48 | 16 |