blob: c9788b854063475f387111da80e931fe76db301e (
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
|
package com.vaadin.tests.components.ui;
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.tests.util.Log;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
public class InitialFragmentEvent extends AbstractTestUI {
private String lastKnownFragment = "\"no event received\"";
private Log log = new Log(5);
@Override
protected void setup(VaadinRequest request) {
getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() {
public void uriFragmentChanged(UriFragmentChangedEvent source) {
String newFragment = source.getUriFragment();
log.log("Fragment changed from " + lastKnownFragment + " to "
+ newFragment);
lastKnownFragment = newFragment;
}
});
addComponent(log);
addComponent(new Button("Set fragment to 'foo'",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
setFragment("foo");
}
}));
addComponent(new Button("Set fragment to 'bar'",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
setFragment("bar");
}
}));
}
protected void setFragment(String fragment) {
getPage().setUriFragment(fragment);
}
@Override
protected Integer getTicketNumber() {
// TODO Auto-generated method stub
return null;
}
@Override
protected String getTestDescription() {
// TODO Auto-generated method stub
return null;
}
}
|