integrate Bootstrap and GWT
Asked Answered
A

2

6

I'm investigating the best practices to use Bootstrap library with GWT. I prefer not use the GWT-Bootstrap project and prefer to use plain css and js Bootstrap library in my GWT app.

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

Astrolabe answered 25/10, 2012 at 21:18 Comment(0)
R
12

No, there's no way to simple add the bootstrap styles to gwt components. You will have to deal with DOM, remove some GWT CSS classes and add GWT ones instead, and, at least you copy your code from one place to everywhere, you will made a class that extend the original component and use this new class everywhere, which is basically what GWT-Bootstrap do.

I know this because about one year ago, I wanted to do exactly what you're saying now: apply bootstrap styles to GWT components in a clean way, than, I managed it to work, and start the GWT-Bootstrap development.

GWT-Bootstrap actually already solved the most of the gwt+bootstrap integration bugs, and works well for basically any project. I know that some components are not implemented yet or have bugs, but, maybe you can fix some and made a pull-request, IMHO, that's better than rebuild all the things.

Radial answered 26/10, 2012 at 10:33 Comment(4)
see the last 2 posts of this thread (namely the whole thread discuss gwt and gwt-bootstrap) : groups.google.com/forum/?fromgroups=#!topic/gwt-platform/…Astrolabe
i mean in thread above Kyle Anderson in his first posts ahve been argumentaing against gwt-bootsrap and says he prefers using plain Bootsrap in GWT over gwt-bootsrap. i was willing to participate in the discussion with you arguments why gwt-bootsrap is better for GWT apps over plain BS.Astrolabe
because it's basically the same. GWT-Bootstrap is nothing more than Wrappers to gwt widgets plus BS styles and JS. But, sure, you can reinvent the wheel and do it by yourself. Your choice.Radial
peopele are worried about keeping their BS lib up to date with newer BS versions. so using Plain BS will not be reinventing the wheel if some GWT projects needs to keep their BS version up to date. unless GWT-BS is able to keep up with every new upgrade of the BS-twitter library then in this case it will be definitely a good choice.Astrolabe
W
2

You certainly can use Bootstrap and GWT without a third-party wrapper library, adding Bootstrap's CSS classes with the addStyleNames attribute in UiBinder XML or the same method in Java code. But Bootstrap also works heavily with custom data attributes like data-toggle for instance to let the "magic" happen. Since GWT's default widgets (FlowPanel etc.) don't offer setters for these custom attributes you can't set them in UiBinder XML and find yourself writing lots of

getElement().setAttribute(...)

in your Java code.

That's what wrapper libraries like GWT-Bootstrap or GwtBootstrap3 are for. They offer custom widgets that wrap these functionalities so that you can use Bootstrap widgets as you are used to with default GWT widgets.

Whereon answered 18/8, 2013 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.