GWT: use the same user interface template for multiple pages?

How can I use the same user interface template (* .ui.xml file) with multiple Java objects extending from Composite?

I need to create several pages that should display basically the same information with the same layout, but on one page some fields will be editable, and on the other page other fields will be available. I would like to specify the layout only once in ui.xml and create different types of behavior in different * .java classes.

Eclipse gives me the syntax error "FirstAppUI.ui.xml is missing" on

@UiTemplate("Template.ui.xml") public class FirstAppUI extends Composite { interface FirstAppUIUiBinder extends UiBinder<Widget, FirstAppUI> { } } 

thanks! Jane Prusakova

+4
source share
1 answer

It seems to me that you need to place the @UiTemplate annotation on the Binder , and not on the Composite class

This code works for me:

 public class TestUiBinder extends Composite { @UiTemplate("SomeTemplate.ui.xml") interface TestUiBinderUiBinder extends UiBinder<Widget, TestUiBinder> {} private static TestUiBinderUiBinder uiBinder = GWT.create(TestUiBinderUiBinder.class); public TestUiBinder() { initWidget(uiBinder.createAndBindUi(this)); } } public class AnotherTestUiBinder extends Composite { @UiTemplate("SomeTemplate.ui.xml") interface TestUiBinderUiBinder extends UiBinder<Widget, AnotherTestUiBinder> {} private static TestUiBinderUiBinder uiBinder = GWT.create(TestUiBinderUiBinder.class); public AnotherTestUiBinder() { initWidget(uiBinder.createAndBindUi(this)); } } 

This is similar to the decision to apply different templates to the same widgets .

+8
source

Source: https://habr.com/ru/post/1306845/


All Articles