Browse Source

Fixed problem with Table calling markAsDirty in paint (#10071)

AbstractCommunicationManager now sets the writingResponse flag after calling beforeClientResponse to adhere to beforeClientResponse javadoc which says markAsDirty is ignored if called from beforeClientResponse.

Change-Id: I58f4d009c85bef6756e2f2938d6f42ed88e11143
tags/7.0.0.beta7
Artur Signell 11 years ago
parent
commit
0fb5ddb96c

+ 13
- 14
server/src/com/vaadin/server/AbstractCommunicationManager.java View File

@@ -820,22 +820,21 @@ public abstract class AbstractCommunicationManager implements Serializable {
requireLocale(session.getLocale().toString());
}

uiConnectorTracker.setWritingResponse(true);
try {
dirtyVisibleConnectors
.addAll(getDirtyVisibleConnectors(uiConnectorTracker));

dirtyVisibleConnectors
.addAll(getDirtyVisibleConnectors(uiConnectorTracker));

getLogger().log(
Level.FINE,
"Found " + dirtyVisibleConnectors.size()
+ " dirty connectors to paint");
for (ClientConnector connector : dirtyVisibleConnectors) {
boolean initialized = uiConnectorTracker
.isClientSideInitialized(connector);
connector.beforeClientResponse(!initialized);
}
getLogger().log(
Level.FINE,
"Found " + dirtyVisibleConnectors.size()
+ " dirty connectors to paint");
for (ClientConnector connector : dirtyVisibleConnectors) {
boolean initialized = uiConnectorTracker
.isClientSideInitialized(connector);
connector.beforeClientResponse(!initialized);
}

uiConnectorTracker.setWritingResponse(true);
try {
outWriter.print("\"changes\":[");

List<InvalidLayout> invalidComponentRelativeSizes = null;

+ 9
- 0
server/src/com/vaadin/ui/Table.java View File

@@ -2867,6 +2867,15 @@ public class Table extends AbstractSelect implements Action.Container,
}
}

@Override
public void beforeClientResponse(boolean initial) {
super.beforeClientResponse(initial);

// Ensure pageBuffer is filled before sending the response to avoid
// calls to markAsDirty during paint
getVisibleCells();
}

/*
* (non-Javadoc)
*

+ 71
- 0
uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html View File

@@ -0,0 +1,71 @@
<?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/" />
<title>DisableEnableCascadeStyles</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">DisableEnableCascadeStyles</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/run/com.vaadin.tests.components.table.RemoveItemOnClick?restartApplication</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td>
<td>This is item 3</td>
</tr>
<tr>
<td>mouseClick</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td>
<td>60,11</td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td>
<td>This is item 4</td>
</tr>
<tr>
<td>mouseClick</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[0]</td>
<td>60,11</td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[0]</td>
<td>This is item 8</td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
<td>This is item 0</td>
</tr>
<tr>
<td>mouseClick</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
<td>68,12</td>
</tr>
<tr>
<td>mouseClick</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
<td>68,12</td>
</tr>
<tr>
<td>mouseClick</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
<td>68,12</td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
<td>This is item 4</td>
</tr>
</tbody></table>
</body>
</html>

+ 70
- 0
uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java View File

@@ -0,0 +1,70 @@
/*
* Copyright 2011 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.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Table;

public class RemoveItemOnClick extends AbstractTestUI {

private Table table;

@Override
protected void setup(VaadinRequest request) {
table = new Table();
IndexedContainer ic = new IndexedContainer();
populate(ic);
table.setContainerDataSource(ic);
table.setPageLength(20);
table.setSelectable(true);
table.setImmediate(true);
table.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
table.removeItem(table.getValue());
}
});
addComponent(table);
}

private void populate(Container container) {
container.addContainerProperty("property1", String.class, "foo");
container.addContainerProperty("property2", Integer.class, 1210);
container.addContainerProperty("property3", String.class, "bar");

for (int i = 0; i < 100; i++) {
Item item = container.addItem("Item " + i);
item.getItemProperty("property1").setValue("This is item " + i);
}
}

@Override
protected String getTestDescription() {
return "Selecting a row should remove that row from the table";
}

@Override
protected Integer getTicketNumber() {
return 10071;
}

}

Loading…
Cancel
Save