blob: 591a045e1d22416e9e3fec7eee9bc5882b69048c (
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
|
package com.vaadin.tests.components.ui;
import com.vaadin.server.Page;
import com.vaadin.server.Page.FragmentChangedEvent;
import com.vaadin.server.WrappedRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
public class UriFragmentTest extends AbstractTestUI {
private final Label fragmentLabel = new Label();
@Override
protected void setup(WrappedRequest request) {
addComponent(fragmentLabel);
updateLabel();
getPage().addListener(new Page.FragmentChangedListener() {
@Override
public void fragmentChanged(FragmentChangedEvent event) {
updateLabel();
}
});
addComponent(new Button("Navigate to #test",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getPage().setFragment("test");
}
}));
}
private void updateLabel() {
String fragment = getPage().getFragment();
if (fragment == null) {
fragmentLabel.setValue("No URI fragment set");
} else {
fragmentLabel.setValue("Current URI fragment: " + fragment);
}
}
@Override
public String getTestDescription() {
return "URI fragment status should be known when the page is loaded and retained while navigating to different fragments or using the back and forward buttons.";
}
@Override
protected Integer getTicketNumber() {
return Integer.valueOf(8048);
}
}
|