1
votes

If I have the following class com.mywebapp.client.ui.MyWidget:

public class MyWidget extends Composite {
    interface MyWidgetUiBinder extends UiBinder<Widget, MyWidget>{}
    private static MyWidgetUiBinder uiBinder = GWT.create(MyWidgetUiBinder.class);

    ...
}

And it's corresponding UiBinder:

<!-- MyWidgetUiBinder.ui.xml -->
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'>
    <!-- ... -->
</ui:UiBinder>

Then:

  1. Where (what package or folder) does MyWidgetUiBinder.ui.xml go? Does GWT allow you to make this configurable or does it require that you place it somewhere specifically?
  2. How granular should UiBinder snippets be? For every Widget? For every display region? 1 per "page"/screen?

Thanks in advance!

2

2 Answers

0
votes

UiBinder looks for a file named after the enclosing class of the interface (if any, otherwise the interface name), in the same package as that class.

In your case, it'll look for a com/mywebapp/client/ui/MyWidget.ui.xml.

This is the default, and can be overridden using @UiTemplate. See https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder#Apply_different_xml

As for the granularity, UiBinder templates should be kept an implementation detail of a widget.

0
votes
  1. Where (what package or folder) does MyWidgetUiBinder.ui.xml go? Does GWT allow you to make this configurable or does it require that you place it somewhere specifically?

GWT requires the ui.xml file to be in the same folder (the source folder) as the .java file. If you use the GWT plugin for eclipse, it will warn you if the file isn't there. You can also use the @UiTemplate annotation on your interface (MyWidgetUiBinder) to specify different location if you really need to.

  1. How granular should UiBinder snippets be? For every Widget? For every display region? 1 per "page"/screen?

That really depends. I like to start with a single UiBinder per page, and then break the re-useable parts out of that.