summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/tests/tickets/Ticket932.java
blob: 6a8a459042799a4f0c99ce90a703c060359a6ce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.vaadin.tests.tickets;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;

public class Ticket932 extends Application {

    @Override
    public void init() {

        final Window mainWin = new Window("Test app for max length feature");
        setMainWindow(mainWin);

        final TextField tx = new TextField(
                "Textfield with maxlenght 10, single row");
        tx.setImmediate(true);
        tx.setMaxLength(10);

        final Label l = new Label();

        Button b = new Button("Check value");
        b.addListener(new Button.ClickListener() {

            public void buttonClick(ClickEvent event) {
                l.setValue("Length: " + tx.getValue().toString().length()
                        + " Content: " + tx.getValue());
            }
        });

        mainWin.addComponent(tx);
        mainWin.addComponent(b);

        final TextField tx2 = new TextField(
                "Textfield with maxlenght 10, multirow ");
        mainWin.addComponent(tx2);
        tx2.setImmediate(true);
        tx2.setRows(5);
        tx2.setMaxLength(10);

        Button b2 = new Button("Check value");
        b2.addListener(new Button.ClickListener() {

            public void buttonClick(ClickEvent event) {
                l.setValue("Length: " + tx2.getValue().toString().length()
                        + " Content: " + tx2.getValue());
            }
        });

        mainWin.addComponent(tx);
        mainWin.addComponent(b);

        mainWin.addComponent(l);

        final RichTextArea rta = new RichTextArea();
        rta.setCaption("RTA with max lenght 10");

        rta.setMaxLength(10);

        b = new Button("Check value");
        b.addListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                l.setValue("Length: " + rta.getValue().toString().length()
                        + " Content: " + rta.getValue());
            }
        });

        mainWin.addComponent(rta);
        mainWin.addComponent(b);

    }

}