1 package com.vaadin.tests.components.abstractfield;
3 import com.vaadin.tests.components.TestBase;
4 import com.vaadin.tests.util.Log;
5 import com.vaadin.v7.data.Property.ValueChangeEvent;
6 import com.vaadin.v7.data.Property.ValueChangeListener;
7 import com.vaadin.v7.data.util.ObjectProperty;
8 import com.vaadin.v7.data.validator.DoubleValidator;
9 import com.vaadin.v7.data.validator.IntegerValidator;
10 import com.vaadin.v7.ui.TextField;
12 public class IntegerDoubleFieldsWithDataSource extends TestBase {
14 private Log log = new Log(5);
17 protected void setup() {
20 TextField tf = createIntegerTextField();
21 tf.addValidator(new IntegerValidator("Must be an Integer"));
24 tf = createIntegerTextField();
25 tf.setCaption("Enter a double");
26 tf.setPropertyDataSource(new ObjectProperty<Double>(2.1));
27 tf.addValidator(new DoubleValidator("Must be a Double"));
31 private TextField createIntegerTextField() {
32 final TextField tf = new TextField("Enter an integer");
33 tf.setPropertyDataSource(new ObjectProperty<Integer>(new Integer(2)));
34 tf.setImmediate(true);
35 tf.addListener(new ValueChangeListener() {
38 public void valueChange(ValueChangeEvent event) {
40 log.log("Value for " + tf.getCaption() + " changed to "
42 log.log("Converted value is " + tf.getConvertedValue());
43 } catch (Exception e) {
44 // TODO: handle exception
54 protected String getDescription() {
55 // TODO Auto-generated method stub
60 protected Integer getTicketNumber() {
61 // TODO Auto-generated method stub