Problems with Only Java-Based Layout
• Hard to format HTML in Java
– Think servlets vs. JSP
– HTML-based layout is usually not dynamic enough
• If it is, use it!
• Hard to visualize the layout
– Not easy to see final result from looking at Java code
• Hard to effectively involve a graphic UI Web designer
– They usually don’t know Java
– Even if you manage to get the design into Java, it is hard to maintain
UiBinder: Main Idea
• Use XML file to lay out chunk of content
– Can represent HTML or a Widget
• Make Java class that represents that chunk
of content
– There are some overly-details steps involved, but Eclipse
has shortcuts that automate making most of them
• Use that Java class in your main application
– If class represents HTML, use the GWT DOM API to
insert it
– If class represents a Widget, use normal “add” method to
insert it
Advantages of UiBinder
• Can make complex page layouts using HTML
– Or HTML-like XML
• Analogous to adding JSP to pure-servlet apps
• More maintainable
• Graphic Web designers can be involved from
initial design through maintenance
– Easy to start with regular HTML and gradually “sprinkle in”
GWT bindings
• Separation of concerns
– Aesthetics and functionality of UI no longer mashed together
• Compile-time check of cross references
between XML & Java and even within XML itself
• Better browser performance
– Browsers are very fast at stuffing long strings into
innerHTML of an element
• Not so much when it comes to executing JavaScript APIs
– Lesson: use regular HTML whenever possible!
– Goal of UiBinder: Make the easier choice the right choice