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) {
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();
.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());
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);
}
}));
+ 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",
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);
}