javagwttwitter-bootstrap-3uibindergwtbootstrap3

Gwtbootstrap3. Using bootstrap component only with java code- without ui-binder


Is there possibile to use bootstrap3 elements (from gwtboostrap3 library) without using ui binder, but using java code like it is done with gwt regular widgets?

I could not find a word about it in Documentation.

F.E. Lets take button widget from gwt:

  public void onModuleLoad() {
    // Make a new button that does something when you click it.
    Button b = new Button("Jump!", new ClickHandler() {
      public void onClick(ClickEvent event) {
        Window.alert("How high?");
      }
    });

    // Add it to the root panel.
    RootPanel.get().add(b);
  }
}

Which will create:

<button type="button" class="gwt-Button">Jump!</button>

In gwtbootstrap3 I have to do something like that:

<b:Button type="DEFAULT"/>

Please help me with that.

Is it possible to use gwtbootstrap3 library components like button with pure java instead of uibinder xml files?

Is there solution that works out of box?

Or maybe I should write my own classess that extends native gwt widget an add bootstrap releated css classes?


Solution

  • Yes!

    You can use the widget as you please, refer to the their javadoc to see what constructors they have! They are a different set of widgets and might not be analogue of GWT standard widgets.

    Bonus

    GWT UiBinder does no different than you, all it does is reduce the boilerplate, generating java classes that automate the instantiate of the widgets. You can add the compiler option -gen to see these transient classes. Usually , they are deleted after GWT compiles your application, as they are no longer needed. Take a look the the compiler documentation for more info!