0

I have a <div> in My.html file:

<html><head>
<script type="text/javascript" language="javascript" src="
 path/biz.path.nocache.js"></script></head>
 <div id = "div_test"> </div>

Now i wrote a java class which fetch the test division using Dom.

private void AddWidget() throws Exception{
 _obj = new testWidget(this._session);
 _obj.setSize("100%", "100%");
 _obj.AddTestWidget();
 RootPanel rootpanel = getViewRootPanel(div_test); // returns the division id 
 rootpanel.clear();
 rootpanel.add(_obj);   
}

and following is TestWidget.java:

public class TestWidget extends ContentContainer{
  HorizontalPanel _base = new HorizontalPanel();
  protected FlexTable _bill = new FlexTable();
  Label lblTitle;

  public TestWidget(Session s) {
    super(s);
    _base.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    _base.setWidth("100%");
    initWidget(_base);
    this._session= s;
    _inheritwidget = new InheritWidget(session);
  }
  public Widget AddTestWidget() {
    System.out.println("In widget");
    lblTitle= new Label("Details");
    lblTitle.setStyleName(Resources.INSTANCE.cssElements().labelBig());
    lblTitle.getElement().getStyle().setPadding(3, Unit.PX);
    _inheritwidget .setWidget(1, 0, lblBillingTitle);
    _inheritwidget .setWidget(2, 0, billingWidget);
    _base.add(_billing);
return _base;
}
}

where InheritWidget class is extended from ContentContainer. I also check the console and it shows me In Widget. It means the flow of code is right. Please tell me what should i do to load the content of AddTestWidget in HTML div.

Is there any part which i am missing?

Amit Pal
  • 10,604
  • 26
  • 80
  • 160
  • What does getViewRootPanel() do? What is the hierarchy of ContentContainer? Cross check you code snippets for other spell checks which might be misleading. It would be easy if we could copy paste you code snippets to run instead of second guessing your question. – appbootup Dec 09 '12 at 17:43

2 Answers2

4

What is ContentContainer? I am unable to find it in the GWT library. Your TestWidget does not extend the GWT Widget class. Because of this, you can't use it as a widget. If you MUST extend ContentContainer for your coding needs, you can implement the GWT isWidget interface to let GWT know that it is a widget.

Churro
  • 4,166
  • 3
  • 25
  • 26
0
RootPanel.get().add(Your widget) 
Abhijith Nagaraja
  • 3,370
  • 6
  • 27
  • 55