Browse Source

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
tags/7.1.8
Matti Tahvonen 10 years ago
parent
commit
1b7e40de94

+ 5
- 0
client/src/com/vaadin/client/ui/VScrollTable.java View File

@@ -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;

+ 58
- 0
uitest/src/com/vaadin/tests/components/table/EmptyTable.java View File

@@ -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;
}

}

+ 44
- 0
uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java View File

@@ -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!");
}

}

Loading…
Cancel
Save