Sadly the event listener is not working on the added element. It's only working on the initial elements.
table = new CellTable<Contact>() {
public void onBrowserEvent2(Event event) {
Element tr = Element.as(event.getEventTarget());
boolean gotIt = false;
while (!gotIt && tr != null) {
if (!tr.getTagName().equals("TR")) {
tr = tr.getParentElement();
continue;
}
gotIt = true;
}
if (tr == null)
return;
tr = Element.as(tr.getChild(1));
Element out = DOM.createDiv();
out.setInnerHTML("<a href='xxx'>Edit contact</a> | <a href='xxx'>Add visit plan</a> | <a href='xxx'>New visit</a>");
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEOVER:
tr.appendChild(out);
break;
case Event.ONMOUSEOUT:
tr.getChild(1).removeFromParent();
break;
}
}
};
If you are fine with it you can have all your handlers declared separately.
You can always add Mouse Handlers directly like this:
//code depicting a MouseOverHandler. Use this for any type of GWT Event Handler
CellTable<String> cellTable = new CellTable<String>();
cellTable.addDomHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
// Your logic
}
}, MouseOverEvent.getType());
That should help