gwtjscrollpanejquery-jscrollpanegwtquerygquery

GWT: I am using jScrollPane with jquery, is it messing with my ClickHandlers?


I implemented the JScrollPane for a cleaner look inside my Page.

function scrollPane() {
$(".gwt-content").jScrollPane();
}

A custom Widget gets added:

$(".jspPane").append($(new Content());

works

$(html).click(new Function() {
public boolean f(Event e) {
System.out.println("yo");
return true;
}
});

doesn't

html.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
System.out.println("yo1");
}
});

html is a HTML Widget with some Text and another HTML widget in it.

The real problem is: I want to add a CellTable into the jspPane, but the listener in the ClickableTextCell is removed. I don't know if I can implement a CellTable and use GWTQuery to add a ClickListener.

Well, any help is appreciated, if you need more infos or source tell me.

Thanks


Solution

  • In order that the JScrollPane could contain a widget, you have to promote it to a gwt panel since it has been created by jquery.

    Gwt is strict in the sense that you must have a consistent widget hierarchy.

    Gquery manipulates the dom, and elements of widgets added with it are treated as elements and are not inserted in the widgets tree unless you use specific methods present in gwtquery to do that.

    You can solve your problem using either way:

    Gquery: this only works with last snapshot

    Widget myContent = new Content();
    Panel jsPane = $(".jspPane").as(Widgets.Widgets).panel().widget();
    jsPane.add(myContent);
    

    Gwt: here you have to set an id to your jsPane

    Widget myContent = new Content();
    Panel jsPane = RootPanel.get("jsPaneId");
    jsPane.add(myContent);