diff options
author | Automerge <automerge@vaadin.com> | 2012-05-03 13:06:20 +0000 |
---|---|---|
committer | Automerge <automerge@vaadin.com> | 2012-05-03 13:06:20 +0000 |
commit | 015306c0e2bcc8701a352a331e78deb0c867f924 (patch) | |
tree | ccbce7515158dc350d2802339044bc13c84b4285 /src/com | |
parent | ab6017f8a9922e5b3421035a087ba68fb14e9200 (diff) | |
download | vaadin-framework-015306c0e2bcc8701a352a331e78deb0c867f924.tar.gz vaadin-framework-015306c0e2bcc8701a352a331e78deb0c867f924.zip |
[merge from 6.7] Don't paint references to orphan components #8730
svn changeset:23668/svn branch:6.8
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/vaadin/event/dd/acceptcriteria/SourceIs.java | 27 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java | 9 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java b/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java index 8562bc70ec..0d29e9a327 100644 --- a/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java +++ b/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java @@ -6,6 +6,9 @@ */ package com.vaadin.event.dd.acceptcriteria; +import java.util.logging.Level; +import java.util.logging.Logger; + import com.vaadin.event.TransferableImpl; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.terminal.PaintException; @@ -22,27 +25,39 @@ import com.vaadin.ui.Component; @SuppressWarnings("serial") @ClientCriterion(VDragSourceIs.class) public class SourceIs extends ClientSideCriterion { + private static final Logger logger = Logger.getLogger(SourceIs.class + .getName()); - private Component[] component; + private Component[] components; public SourceIs(Component... component) { - this.component = component; + components = component; } @Override public void paintContent(PaintTarget target) throws PaintException { super.paintContent(target); - target.addAttribute("c", component.length); - for (int i = 0; i < component.length; i++) { - target.addAttribute("component" + i, component[i]); + int paintedComponents = 0; + for (int i = 0; i < components.length; i++) { + Component c = components[i]; + if (c.getApplication() != null) { + target.addAttribute("component" + paintedComponents++, c); + } else { + logger.log( + Level.WARNING, + "SourceIs component {0} at index {1} is not attached to the component hierachy and will thus be ignored", + new Object[] { c.getClass().getName(), + Integer.valueOf(i) }); + } } + target.addAttribute("c", paintedComponents); } public boolean accept(DragAndDropEvent dragEvent) { if (dragEvent.getTransferable() instanceof TransferableImpl) { Component sourceComponent = ((TransferableImpl) dragEvent .getTransferable()).getSourceComponent(); - for (Component c : component) { + for (Component c : components) { if (c == sourceComponent) { return true; } diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index d6c53a2da6..97c5139296 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -698,6 +698,15 @@ public class JsonPaintTarget implements PaintTarget { public String getPaintIdentifier(Paintable paintable) throws PaintException { if (!manager.hasPaintableId(paintable)) { + if (paintable instanceof Component + && ((Component) paintable).getApplication() == null) { + logger.log( + Level.WARNING, + "Painting reference to orphan " + + paintable.getClass().getName() + + ", the component will not be accessible on the client side."); + return "Orphan"; + } if (identifiersCreatedDueRefPaint == null) { identifiersCreatedDueRefPaint = new HashSet<Paintable>(); } |