* If title is null, leave it as-is (assume somebody else is setting it) * If title is non-null, set it as before Change-Id: I72699efa089df64b58448ceef59ba31995f330bftags/7.2.0.beta1
@@ -680,8 +680,10 @@ public class UIConnector extends AbstractSingleComponentContainerConnector | |||
} | |||
if (stateChangeEvent.hasPropertyChanged("pageState.title")) { | |||
com.google.gwt.user.client.Window | |||
.setTitle(getState().pageState.title); | |||
String title = getState().pageState.title; | |||
if (title != null) { | |||
com.google.gwt.user.client.Window.setTitle(title); | |||
} | |||
} | |||
if (stateChangeEvent.hasPropertyChanged("pushConfiguration")) { |
@@ -1133,9 +1133,12 @@ public class Page implements Serializable { | |||
/** | |||
* Sets the page title. The page title is displayed by the browser e.g. as | |||
* the title of the browser window or as the title of the tab. | |||
* <p> | |||
* If the title is set to null, it will not left as-is. Set to empty string | |||
* to clear the title. | |||
* | |||
* @param title | |||
* the new page title to set | |||
* the page title to set | |||
*/ | |||
public void setTitle(String title) { | |||
getState(true).title = title; |
@@ -32,7 +32,7 @@ public class PageState implements Serializable { | |||
public boolean hasResizeListeners = false; | |||
/** | |||
* Non-null if the title is set. | |||
* Non-null if the title is set. Null means Vaadin does not touch the title. | |||
*/ | |||
public String title = null; | |||
} |
@@ -0,0 +1,44 @@ | |||
/* | |||
* Copyright 2000-2013 Vaadin Ltd. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |||
* use this file except in compliance with the License. You may obtain a copy of | |||
* the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.components.page; | |||
import com.vaadin.annotations.Title; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
@Title("bar") | |||
public class PageTitle extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
String title = request.getParameter("title"); | |||
if (title != null) { | |||
getPage().setTitle(title); | |||
} | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Sets the title according to a given ?title parameter. By default the ApplicationServletRunner will set the title to the fully qualified class name"; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 13430; | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
/* | |||
* Copyright 2000-2013 Vaadin Ltd. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |||
* use this file except in compliance with the License. You may obtain a copy of | |||
* the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.components.page; | |||
import org.junit.Assert; | |||
import org.junit.Test; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
public class PageTitleTest extends MultiBrowserTest { | |||
@Test | |||
public void nullTitle() { | |||
driver.get(getTestUrl()); | |||
Assert.assertEquals(PageTitle.class.getName(), driver.getTitle()); | |||
} | |||
@Test | |||
public void fooTitle() { | |||
driver.get(getTestUrl() + "?title=foo"); | |||
Assert.assertEquals("foo", driver.getTitle()); | |||
} | |||
} |