diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-08-02 12:11:08 +0000 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-08-02 12:11:08 +0000 |
commit | 6685816c2a548bad3d827d3064a70f35e7b69361 (patch) | |
tree | 585521325eacebef2fc930e2cbb7938befffbd1e /src/com | |
parent | 85c03155dc02e61dd10a9c861b064204bdeaca9f (diff) | |
download | vaadin-framework-6685816c2a548bad3d827d3064a70f35e7b69361.tar.gz vaadin-framework-6685816c2a548bad3d827d3064a70f35e7b69361.zip |
Clear selectionRangeStart if the key map has been cleared (#8584, #8736)
svn changeset:24045/svn branch:6.8
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java | 20 | ||||
-rw-r--r-- | src/com/vaadin/ui/Table.java | 16 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index c1f90b0157..e54493ca61 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -109,6 +109,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, public static final String ATTRIBUTE_PAGEBUFFER_FIRST = "pb-ft"; public static final String ATTRIBUTE_PAGEBUFFER_LAST = "pb-l"; + /** + * Tell the client that old keys are no longer valid because the server has + * cleared its key map. + */ + public static final String ATTRIBUTE_KEY_MAPPER_RESET = "clearKeyMap"; + private static final String ROW_HEADER_COLUMN_KEY = "0"; public static final String CLASSNAME = "v-table"; @@ -1051,6 +1057,20 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } } + /* + * If the server has (re)initialized the rows, our selectionRangeStart + * row will point to an index that the server knows nothing about, + * causing problems if doing multi selection with shift. The field will + * be cleared a little later when the row focus has been restored. + * (#8584) + */ + if (uidl.hasAttribute(ATTRIBUTE_KEY_MAPPER_RESET) + && uidl.getBooleanAttribute(ATTRIBUTE_KEY_MAPPER_RESET) + && selectionRangeStart != null) { + assert !selectionRangeStart.isAttached(); + selectionRangeStart = focusedRow; + } + tabIndex = uidl.hasAttribute("tabindex") ? uidl .getIntAttribute("tabindex") : 0; setProperTabIndex(); diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index e96636dd70..e56f6003ab 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -413,6 +413,13 @@ public class Table extends AbstractSelect implements Action.Container, private boolean painted = false; + /** + * Set to true if the client-side should be informed that the key mapper has + * been reset so it can avoid sending back references to keys that are no + * longer present. + */ + private boolean keyMapperReset; + /* Table constructors */ /** @@ -2772,6 +2779,11 @@ public class Table extends AbstractSelect implements Action.Container, paintVisibleColumns(target); + if (keyMapperReset) { + keyMapperReset = false; + target.addAttribute(VScrollTable.ATTRIBUTE_KEY_MAPPER_RESET, true); + } + if (dropHandler != null) { dropHandler.getAcceptCriterion().paint(target); } @@ -3923,6 +3935,10 @@ public class Table extends AbstractSelect implements Action.Container, public void containerItemSetChange(Container.ItemSetChangeEvent event) { super.containerItemSetChange(event); + // super method clears the key map, must inform client about this to + // avoid getting invalid keys back (#8584) + keyMapperReset = true; + // ensure that page still has first item in page, ignore buffer refresh // (forced in this method) setCurrentPageFirstItemIndex(getCurrentPageFirstItemIndex(), false); |