问题
which is better in GWT interface, using the normal MVP with javacode, or UiBinder?? from performance, editing, simplicity aspects.
回答1:
This is what Google says:
Besides being a more natural and concise way to build your UI than doing it through code, UiBinder can also make your app more efficient. Browsers are better at building DOM structures by cramming big strings of HTML into innerHTML attributes than by a bunch of API calls. UiBinder naturally takes advantage of this, and the result is that the most pleasant way to build your app is also the best way to build it.
So probably judging by the points you mentioned, UiBinder provides more advantages. However, I wouldn't do everything in UiBinder. Just start with it, and you'll find out, where a little bit of pure code might be a better (or the only) choice!
回答2:
The direct answer to your question is : BOTH! :)
Simply build the MVP architecture then build each VIEW using the UiBinder. This is what I have been doing and it work perfectly. UiBinders can be attached to whatever class you want, as long as it has the same name as your class. (EX: YourView.java + YourView.ui.xml)
There is a tutorial in GWT doc that explain the UiBinder, although it's missing many important point.
I will soon be releasing a project with that architecture on Google code using the GPL. If you're interested, I can add the URL here when it's out so you can have a direct example of how they work together.
I also suggest you use ClientBundles for all your CSS and Images. If you want argument on the matter, there is plenty in GWT tutorial of ClientBundles. I've also integrated them perfectly with my MVP+UiBinder architecture and it work like a charm. The only problem here is that the ClientBindle tutorial was missing many important information so I had to play around a lot to make it work perfectly.
For each VIEW, I'd always use UiBinder. But for some simple Composite (homemade widget), I'd say it is sometime best to use direct javacode as Chris_l said.
来源:https://stackoverflow.com/questions/2720137/which-is-better-in-gwt