Browse Source

Fixes @PreserveOnRefresh losing page title on refresh #11054

Moves Page title to PageState instead of using RPC for changing the title on Page.setTitle().

Change-Id: I8e5ab2064c04235503fb2531f4cdbb108530ac7e
tags/7.2.0.beta1
Joonas Lehtinen 11 years ago
parent
commit
104e472d21

+ 5
- 4
client/src/com/vaadin/client/ui/ui/UIConnector.java View File

@@ -100,10 +100,6 @@ public class UIConnector extends AbstractSingleComponentContainerConnector
protected void init() {
super.init();
registerRpc(PageClientRpc.class, new PageClientRpc() {
@Override
public void setTitle(String title) {
com.google.gwt.user.client.Window.setTitle(title);
}

@Override
public void reload() {
@@ -644,6 +640,11 @@ public class UIConnector extends AbstractSingleComponentContainerConnector
configurePolling();
}

if (stateChangeEvent.hasPropertyChanged("title")) {
com.google.gwt.user.client.Window
.setTitle(getState().pageState.title);
}

if (stateChangeEvent.hasPropertyChanged("pushConfiguration")) {
getConnection().setPushEnabled(
getState().pushConfiguration.mode.isEnabled());

+ 1
- 1
server/src/com/vaadin/server/Page.java View File

@@ -1079,7 +1079,7 @@ public class Page implements Serializable {
* the new page title to set
*/
public void setTitle(String title) {
uI.getRpcProxy(PageClientRpc.class).setTitle(title);
getState(true).title = title;
}

/**

+ 0
- 2
shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java View File

@@ -20,8 +20,6 @@ import com.vaadin.shared.communication.ClientRpc;

public interface PageClientRpc extends ClientRpc {

public void setTitle(String title);

public void reload();

}

+ 5
- 0
shared/src/com/vaadin/shared/ui/ui/PageState.java View File

@@ -30,4 +30,9 @@ public class PageState implements Serializable {
* True if the page has browser window resize listeners.
*/
public boolean hasResizeListeners = false;

/**
* Non-null if the title is set.
*/
public String title = null;
}

+ 36
- 0
uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.html View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://localhost:8888/run/com.vaadin.tests.application.RefreshStatePreserveTitle?restartApplication" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/run/com.vaadin.tests.application.RefreshStatePreserveTitle?restartApplication</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>TEST</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>/run/com.vaadin.tests.application.RefreshStatePreserveTitle</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>TEST</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

+ 30
- 0
uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.java View File

@@ -0,0 +1,30 @@
package com.vaadin.tests.application;

import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Label;

@PreserveOnRefresh
public class RefreshStatePreserveTitle extends AbstractTestUI {

private Log log = new Log(5);

@Override
protected void setup(VaadinRequest request) {
getPage().setTitle("TEST");
addComponent(new Label(
"Refresh the page and observe that window title 'TEST' is lost."));
}

@Override
protected String getTestDescription() {
return "Refreshing the browser window should preserve the window title";
}

@Override
protected Integer getTicketNumber() {
return Integer.valueOf(11054);
}
}

Loading…
Cancel
Save