summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2014-12-19 13:57:23 +0200
committerHenrik Paul <henrik@vaadin.com>2015-01-08 13:50:19 +0200
commitd4e633d49441123bda15c90f4aa657bda31ee43c (patch)
tree8adab68ec8fa7a3be157715ad7c37d8e55237135
parent81165cf0bdb7821f28aa40e9689969adfddb666f (diff)
downloadvaadin-framework-d4e633d49441123bda15c90f4aa657bda31ee43c.tar.gz
vaadin-framework-d4e633d49441123bda15c90f4aa657bda31ee43c.zip
RendererClickEvent now tells about propertyIds (#13334)
Change-Id: I5d67516516c46984c965577653b4fb44ddbaff11
-rw-r--r--server/src/com/vaadin/ui/renderer/ClickableRenderer.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java14
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java9
3 files changed, 32 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/renderer/ClickableRenderer.java b/server/src/com/vaadin/ui/renderer/ClickableRenderer.java
index 851bbf8510..d640ce8b71 100644
--- a/server/src/com/vaadin/ui/renderer/ClickableRenderer.java
+++ b/server/src/com/vaadin/ui/renderer/ClickableRenderer.java
@@ -91,6 +91,15 @@ public class ClickableRenderer<T> extends AbstractRenderer<T> {
public Column getColumn() {
return column;
}
+
+ /**
+ * Returns the property ID where the click event originated.
+ *
+ * @return the property ID of the clicked cell
+ */
+ public Object getPropertyId() {
+ return column.getPropertyId();
+ }
}
protected ClickableRenderer(Class<T> presentationType) {
diff --git a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java
index de6fb30e1c..310cd357fa 100644
--- a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java
+++ b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java
@@ -31,8 +31,11 @@ import com.vaadin.ui.renderer.ClickableRenderer.RendererClickListener;
import com.vaadin.ui.renderer.ImageRenderer;
import com.vaadin.ui.renderer.ProgressBarRenderer;
+@SuppressWarnings("all")
public class WidgetRenderers extends AbstractTestUI {
+ static final String PROPERTY_ID = "property id";
+
@Override
protected void setup(VaadinRequest request) {
IndexedContainer container = new IndexedContainer();
@@ -43,6 +46,7 @@ public class WidgetRenderers extends AbstractTestUI {
.addContainerProperty(ButtonRenderer.class, String.class, null);
container.addContainerProperty(ImageRenderer.class, Resource.class,
null);
+ container.addContainerProperty(PROPERTY_ID, String.class, null);
final Item item = container.getItem(container.addItem());
@@ -50,6 +54,7 @@ public class WidgetRenderers extends AbstractTestUI {
item.getItemProperty(ButtonRenderer.class).setValue("Click");
item.getItemProperty(ImageRenderer.class).setValue(
new ThemeResource("window/img/close.png"));
+ item.getItemProperty(PROPERTY_ID).setValue("Click");
final Grid grid = new Grid(container);
@@ -78,6 +83,15 @@ public class WidgetRenderers extends AbstractTestUI {
}
}));
+ grid.getColumn(PROPERTY_ID).setRenderer(
+ new ButtonRenderer(new RendererClickListener() {
+ @Override
+ public void click(RendererClickEvent event) {
+ item.getItemProperty(PROPERTY_ID).setValue(
+ event.getPropertyId());
+ }
+ }));
+
addComponent(grid);
addComponent(new Button("Change column order",
diff --git a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java
index 864a559fc6..ba8e5135ab 100644
--- a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java
@@ -92,6 +92,15 @@ public class WidgetRenderersTest extends MultiBrowserTest {
By.className("gwt-Button")));
}
+ @Test
+ public void testPropertyIdInEvent() {
+ openTestURL();
+ WebElement button = getGridCell(0, 3).findElement(
+ By.className("gwt-Button"));
+ button.click();
+ assertEquals(WidgetRenderers.PROPERTY_ID, button.getText());
+ }
+
GridCellElement getGridCell(int row, int col) {
return $(GridElement.class).first().getCell(row, col);
}