UIBinder in GWT

I am trying to understand the concept of UIBinder in GWT. I went through a couple of online tutorials. Here is my question:

1) Why exactly one would like to use UIBinder? Is it just because we will write less code and evolve, as if we were writing javascript directly?

2) Is there anything that can be achieved using UiBinder that cannot be performed by GWT or vice versa?

I went through this link, which gives a direct discussion about the same. Any other questions or suggestions?

Thanks in advance.

+7
source share
2 answers

GWT’s biggest advantage in creating the DOM is UiBinders , also known as “ Declarative Layout ,

UiBinders provide you with the ability to declare the layout of your application and widgets using traditional HTML and CSS, rather than programmatically in java. This gives you a much richer way to build your application.

Browsers better structure DOM structures by sorting large HTML strings into innerHTML attributes rather than by linking API calls . UiBinder naturally uses this, and as a result, the most enjoyable way to create your application is the best way to create it.

  • UiBinder is a structure designed to separate functionality and the appearance of the user interface.

  • The UiBinder framework allows developers to create gwt applications as HTML pages with GWT widgets configured on them.

  • The UiBinder structure simplifies interaction with user interface designers who are more comfortable with XML, HTML, and CSS than the Java source code.
  • UIBinder provides a declarative way to define a user interface.

  • UIBinder separates program logic from the user interface.

  • UIBinder is similar to JSPs on servlets.

And here is one example that, like UIBInder, gives an edge over traditional java code.

Getting to your questions (they are observed during development)

  • If you are familiar with HTMl and CSS, you can simply layout to create a structure there (in ui.xml tempaltes) and just play with GWT. This reduces compilation time.

  • Again, you can just write the markup in xml and apply styles and other DOM attributes, where, as in Java code, you need to write no.of lines of code (well, at least 2 and 3), prepare a widget with styles and specific DOM attributes.

In my experience, I have summarized several points here. http://codeinventions.blogspot.in/2014/07/why-to-use-uibinder-in-gwt.html

+10
source

Java-only layout issues

• It is difficult to format HTML in Java - Think of servlets against JSP - HTML layout is usually not dynamic enough • If so, use it! • It’s hard to imagine a layout - It’s not easy to see the end result of viewing Java code • It’s hard to use the web GUI effectively - They usually don’t know Java - Even if you manage to get a Java design, it’s hard to maintain

UiBinder: The main idea

• Use an XML file to place a piece of content - Can represent HTML or a Widget • Make a Java class that represents this piece of content - There are some overly detailed steps, but Eclipse has shortcuts that automate the creation of most of them • Use this Java class in your main application - If the class represents HTML, use the GWT DOM API to paste it - If the class is a widget, use the usual "add" method to paste it

Advantages of UiBinder • Can create complex page layouts using HTML - Or HTML-like XML • Similar to adding JSP to applications with a clean servlet • More convenient • Graphic web designers can initial design due to maintenance - Easy to start with plain HTML and gradually sprinkle GWT binding • Separation of problems - The aesthetics and functionality of the user interface are no longer mashed • Checking the time of cross-references between XML and Java and even within XML itself

• Improved browser performance - Browsers very quickly type long lines in the innerHTML of an element • Not so much when it comes to executing the JavaScript API - Lesson: Use plain HTML if possible! - The goal of UiBinder: make the right choice, the right choice

0
source

All Articles