开发者

Does anybody have a GWT 2.1 CompositePlace example?

My app uses Composites and so the current GWT 2.1 MVP example that keeps track of SimplePanels doesn't work for me.

Google says that I can always create my own CompositePlace, CompositeActivity and CompositePlace.Tokenizer, but well.... given my skill level, I am a little reluctant to go that much开发者_运维问答 into uncharted territory.

Does any of the GWT gurus out there have a working example for me?

Thanks


I found a blog from "Heros" that had the answer for me.

Turns out the trick is to extend LayoutPanel and implement the AcceptsOneWidget interface.

Then you can pass any LayoutPanel to setWidget function.

Here is the full code:

public class OneWidgetLayoutPanel extends LayoutPanel implements AcceptsOneWidget {
    private IsWidget widget = null;

    @Override
    public void setWidget(IsWidget w) {
            if( widget != null) super.remove(widget);
            widget = w;
            if(w != null) super.add(w);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜