raimund@1500: package de.intevation.flys.client.client.utils; raimund@1504: raimund@1504: import java.util.Map; raimund@1504: raimund@1500: import com.google.gwt.core.client.GWT; raimund@1504: raimund@1500: import com.smartgwt.client.widgets.form.DynamicForm; raimund@1500: import com.smartgwt.client.widgets.form.fields.FormItem; raimund@1500: import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; raimund@1500: import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; raimund@1504: raimund@1500: import de.intevation.flys.client.client.FLYSConstants; raimund@1500: raimund@1500: /** raimund@1500: * @author Raimund Renkert raimund@1500: * raimund@1500: * This validator is used for SmartGWT FormItems. raimund@1500: * raimund@1500: * To use this validator an attribute named 'internalType' has to be set. raimund@1500: * Values for 'internalType': raimund@1500: * 'double' raimund@1500: * 'integer' raimund@1500: */ raimund@1500: public class Validator implements ChangedHandler { raimund@1500: raimund@1500: /** The interface that provides i18n messages. */ raimund@1500: protected FLYSConstants MSG = GWT.create(FLYSConstants.class); raimund@1500: raimund@1500: raimund@1500: /** raimund@1500: * raimund@1500: */ raimund@1500: public void onChanged(ChangedEvent e) { raimund@1500: FormItem item = e.getItem(); raimund@1500: DynamicForm form = e.getForm(); raimund@1500: Map errors = form.getErrors(); raimund@1500: String type = item.getAttribute("internalType"); raimund@1500: raimund@1504: validate(item, errors); raimund@1504: form.setErrors(errors, true); raimund@1500: } raimund@1500: raimund@1500: raimund@1504: protected boolean validate(FormItem item, Map errors) { raimund@1504: return true; raimund@1500: } raimund@1500: } raimund@1500: