gwt - Anchor clickHandler doesn' t fire event -


anchor link = new anchor("link");                 link.setstylename("link");                 link.addclickhandler(new clickhandler() {                     @override                     public void onclick(clickevent event) {                         window.alert("mes");                     }                 });                 relhtml.sethtml(relhtml.gethtml()+link); 

having snipset of code html shows correctly, , anchor looks want like, event not fired. help?

when call sethtml, bypassing of gwt architecture , inserting plain-old html page. that's why event handler doesn't work.

the correct way add widget container add family of methods. example, might rootpanel.get().add(link).

it looks building html string insert @ once, ok call add on every individual component.

rootpanel root = rootpanel.get(); root.add(link); root.add(new button("and button!")); root.add(whateverotherwidget); root.add(new html("you can add arbitrary html html widget."); 

Comments