diff options
author | Mikael Grankvist <mgrankvi@vaadin.com> | 2012-12-17 08:35:53 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-12-19 12:56:53 +0000 |
commit | 8a264ec4052cbee467269824e6e9e7c76efd1d07 (patch) | |
tree | 4a3750f6d1fd40fbef384af679b0c72ced7f56ef /uitest | |
parent | f4dd107919715cf18c92709de1909315de92934a (diff) | |
download | vaadin-framework-8a264ec4052cbee467269824e6e9e7c76efd1d07.tar.gz vaadin-framework-8a264ec4052cbee467269824e6e9e7c76efd1d07.zip |
(#9949) Flush focused connector on historyChange
Change-Id: Ia0f41220a038a83fcbcbbe9feebe066cbc626e27
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/uitest/BackButtonTest.java | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/uitest/BackButtonTest.java b/uitest/src/com/vaadin/tests/components/uitest/BackButtonTest.java new file mode 100644 index 0000000000..d5bac0d509 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/uitest/BackButtonTest.java @@ -0,0 +1,117 @@ +package com.vaadin.tests.components.uitest; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.Page.UriFragmentChangedEvent; +import com.vaadin.server.Page.UriFragmentChangedListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class BackButtonTest extends AbstractTestUI { + + private VerticalLayout layout; + + private String value = "Hello"; + private Page1 p1; + private Page2 p2; + + @Override + public void setup(VaadinRequest request) { + getPage().setUriFragment("page1"); + + layout = new VerticalLayout(); + addComponent(layout); + + p1 = new Page1(); + addComponent(p1); + + p2 = new Page2(); + getPage().addUriFragmentChangedListener( + new UriFragmentChangedListener() { + + @Override + public void uriFragmentChanged(UriFragmentChangedEvent event) { + String f = event.getUriFragment(); + if ("page2".equals(f)) { + showPage2(); + } + + if ("page1".equals(f)) { + showPage1(); + } + } + }); + } + + class Page1 extends VerticalLayout { + Label l = new Label(); + + public Page1() { + setSizeFull(); + l.setCaption("Data from Page 1 : " + value); + addComponent(l); + + Button b = new Button("Go to Page 2", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + l.setCaption("Data from Page 1 : " + value); + getPage().setUriFragment("page2"); + } + }); + addComponent(b); + } + } + + private void showPage2() { + removeComponent(p1); + p2.f.setValue(""); + addComponent(p2); + } + + private void showPage1() { + removeComponent(p2); + addComponent(p1); + } + + class Page2 extends VerticalLayout { + private final TextField f = new TextField(); + + public Page2() { + setSizeFull(); + + addComponent(f); + f.addValueChangeListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + value = f.getValue(); + p1.l.setCaption("Data from Page 2 : " + value); + } + }); + + Button b = new Button("Go Back", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getPage().setUriFragment("page1"); + } + }); + addComponent(b); + addComponent(new Label( + "Go back with the back button without creating a blur event on the text field. Text should transfer to page1 label.")); + } + + } + + @Override + protected Integer getTicketNumber() { + return 9949; + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + +} |