Integrate Bootstrap and GWT

I am studying recommendations for using Bootstrap library with GWT. I prefer not to use the GWT-Bootstrap project and prefer to use the regular css and js Bootstrap library in my GWT application.

I'm looking for how I can apply Bootstrap style to GWT UI components? Do I need to do this in the UI view code while working on the DOM components of the GWT components? or is there any other clean way to achieve this integration of GWT and Bootstrap?

+6
source share
2 answers

No, there is no easy way to add bootstrap styles to gwt components. You will have to deal with the DOM, remove some GWT CSS classes and add GWT instead, and at least you copy your code from one place to another place, you will create a class that extends the source component and uses this new class everywhere. what GWT-Bootstrap basically does.

I know this because about a year ago I wanted to do exactly what you are saying now: apply bootstrap styles to GWT components in a clean way, and I managed to work this out and start developing GWT-Bootstrap.

GWT-Bootstrap has actually solved most of the gwt + bootstrap integration errors and works great for any project. I know that some components are not yet implemented or have errors, but maybe you can fix them and make pull-request, IMHO, which is better than rebuilding everything.

+12
source

Of course, you can use Bootstrap and GWT without a third-party wrapper library by adding CSS Bootstrap classes with the addStyleNames attribute in UiBinder XML or the same method in Java code. But Bootstrap also works very well with custom data attributes such as data-toggle , for example, so that "magic" happens. Since the default widgets for GWT ( FlowPanel , etc.) do not offer setters for these custom attributes, you cannot set them in UiBinder XML and find many letters

 getElement().setAttribute(...) 

in your java code.

What are wrapper libraries like GWT-Bootstrap or GwtBootstrap3 for. They offer custom widgets that wrap this functionality so that you can use Bootstrap widgets as you are used to the default GWT widgets.

+2
source

All Articles