You can use the Vaadin table to solve the original problem, more or less similar. The trick is to create a Vaadin container and put components like data in it. On the text side, wrap the label in a VerticalLayout, and then add a click listener. This makes it possible to display βparagraphsβ of XHTML text, detect clicks on them with relative locations, and still process a large number of paragraphs.
You may need to modify your styles.css to allow text wrapping inside the table row, so you get torn rows.
package com.soletta.clickytable; import com.vaadin.Application; import com.vaadin.data.util.IndexedContainer; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.gwt.server.WebApplicationContext; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Window.CloseEvent; import com.vaadin.ui.Window.CloseListener; public class ClickytableApplication extends Application { @Override public void init() { Window mainWindow = new Window("Clickytable 2 Application"); setMainWindow(mainWindow); mainWindow.addListener(new CloseListener(){ public void windowClose(CloseEvent e) { WebApplicationContext context = (WebApplicationContext) getContext(); context.getHttpSession().invalidate(); close(); }}); IndexedContainer container = new IndexedContainer(); container.addContainerProperty("text", VerticalLayout.class, new VerticalLayout()); container.addContainerProperty("edit", Button.class, new Button("Edit")); for (int i = 0; i < 10; i++) { final int index = i; Object item = container.addItem(); Label lbl = new Label("Text Content " + i); VerticalLayout vl = new VerticalLayout(); vl.setWidth(100, Sizeable.UNITS_PERCENTAGE); vl.addComponent(lbl); vl.addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { System.out.println(String.format("Clicked on text %,d at client(%,d,%,d), relative(%,d %,d)\n", index, event.getClientX(), event.getClientY(), event.getRelativeX(), event.getRelativeY())); } }); container.getItem(item).getItemProperty("text").setValue(vl); container.getItem(item).getItemProperty("edit").setValue(new Button("Button " + i)); } Table table = new Table("ClickyTable 2", container); table.setColumnExpandRatio("text", 1); table.setColumnExpandRatio("edit", 0); table.setSizeFull(); VerticalLayout fl = new VerticalLayout(); fl.setSizeFull(); fl.addComponent(table); mainWindow.setContent(fl); } }
With some style changes in place, the result might look something like this:
ClickTable Screen Shot http://www.soletta.com/images/ClickyTable.PNG
source share