Data providers force re-mapping of the corresponding DOM. The code below demonstrates how this works. This example creates a two-level tree in which you can update (regenerate) leaf nodes by pressing the Enter key on the selected root node directory.
I tried to keep the code as simple as possible, all the necessary materials were contained here.
public class TestEntryPoint implements EntryPoint { private static final Logger LOG = Logger.getLogger(TestEntryPoint.class.getName()); class Item { String name; boolean leaf; public Item(String name, boolean leaf) { this.name = name; this.leaf = leaf; } @Override public String toString() { return "Item {name=" + name + ", leaf=" + leaf + "}"; } } class ItemCell extends AbstractCell<Item> { public ItemCell() { super("keydown"); } @Override public void render(Context context, Item value, SafeHtmlBuilder sb) { if (value != null) sb.appendEscaped(value.name); } @Override protected void onEnterKeyDown( Context context, Element parent, Item value, NativeEvent event, ValueUpdater<Item> valueUpdater) { LOG.info("ItemCell.onEnterKeyDown: value=" + value); if (value == null || value.leaf) return; ListDataProvider<Item> leafDataProvider = leafDataProviders.get(value.name); if (leafDataProvider == null) return;
domax source share