diff options
author | Matti Tahvonen <matti@vaadin.com> | 2013-10-04 15:41:06 +0300 |
---|---|---|
committer | Matti Tahvonen <matti@vaadin.com> | 2013-10-09 16:31:21 +0300 |
commit | 1b7e40de9435f2584fe6c7f1b7f69cc448c16cc8 (patch) | |
tree | b7cb69dfbdef6133e99995cfc9b00117bc69e03a | |
parent | 3c842b76ed6ecbf3cf92cb9a7cca3b72e326a2ed (diff) | |
download | vaadin-framework-1b7e40de9435f2584fe6c7f1b7f69cc448c16cc8.tar.gz vaadin-framework-1b7e40de9435f2584fe6c7f1b7f69cc448c16cc8.zip |
Only fetch rows if there are some (#11189)
IE hacks cause calls to onScroll in situations where the cache row fetch
logic is not working correctly (causes JS exception). This change has an
optimization to pass this logic if there are no rows available and this
way fixes the JS exception as well.
Change-Id: I3425f3d75cad8b65e605638343b167abf7b48067
3 files changed, 107 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 104cbbd5b9..0304acd590 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -6913,6 +6913,11 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // fix footers horizontal scrolling tFoot.setHorizontalScrollPosition(scrollLeft); + if (totalRows == 0) { + // No rows, no need to fetch new rows + return; + } + firstRowInViewPort = calcFirstRowInViewPort(); if (firstRowInViewPort > totalRows - pageLength) { firstRowInViewPort = totalRows - pageLength; diff --git a/uitest/src/com/vaadin/tests/components/table/EmptyTable.java b/uitest/src/com/vaadin/tests/components/table/EmptyTable.java new file mode 100644 index 0000000000..d6c30efa5a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/EmptyTable.java @@ -0,0 +1,58 @@ +/* + * 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.table; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Table; + +public class EmptyTable extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + Table table = new Table("Table"); + table.addContainerProperty("testColumn", String.class, null); + table.setPageLength(0); // disable paging + addComponent(table); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Empty Table should not cause JS exception"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 11189; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java b/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java new file mode 100644 index 0000000000..229dc23b9a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java @@ -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.table; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class EmptyTableTest extends MultiBrowserTest { + + @Test + public void test() { + setDebug(true); + openTestURL(); + + ensureNoErrors(); + } + + private void ensureNoErrors() { + try { + getDriver().findElement(By.className("v-Notification")); + } catch (NoSuchElementException e) { + return; + } + Assert.fail("Error notification was shown!"); + } + +}
\ No newline at end of file |