From 0fb5ddb96c889086178ff3d381d58076257a866a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 26 Oct 2012 11:07:38 +0300 Subject: 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 --- .../server/AbstractCommunicationManager.java | 27 ++++---- server/src/com/vaadin/ui/Table.java | 9 +++ .../tests/components/table/RemoveItemOnClick.html | 71 ++++++++++++++++++++++ .../tests/components/table/RemoveItemOnClick.java | 70 +++++++++++++++++++++ 4 files changed, 163 insertions(+), 14 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html create mode 100644 uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index 5bbf8f5cea..43a9ced608 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -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 invalidComponentRelativeSizes = null; diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index d9e1403a03..242593c20d 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -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) * diff --git a/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html b/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html new file mode 100644 index 0000000000..e95dbb3a65 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html @@ -0,0 +1,71 @@ + + + + + + +DisableEnableCascadeStyles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DisableEnableCascadeStyles
open/run/com.vaadin.tests.components.table.RemoveItemOnClick?restartApplication
assertTextvaadin=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]This is item 3
mouseClickvaadin=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]60,11
assertTextvaadin=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]This is item 4
mouseClickvaadin=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]60,11
assertTextvaadin=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]This is item 8
assertTextvaadin=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]This is item 0
mouseClickvaadin=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]68,12
mouseClickvaadin=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]68,12
mouseClickvaadin=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]68,12
assertTextvaadin=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]This is item 4
+ + diff --git a/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java b/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java new file mode 100644 index 0000000000..b13dd37060 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java @@ -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; + } + +} -- cgit v1.2.3