Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT - How to define a Widget outside layout hierarchy in uibinder xml file

Tags:

gwt

uibinder

this is my first post. I hope someone could help me.
I'm looking for a way to define a widget in UiBinder XML layout file separately, without being part of the layout hierachy. Here's a small example:

<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">

<g:Label ui:field="testlabel" text="Hallo" />
<g:HTMLPanel>       
...
</g:HTMLPanel>

The compile fails since the ui:UiBinder element expects only one child element.
In Java Code i will access and bind the Label widget as usual:

@UiField Label testlabel;

For example, this could be useful when you define a Grid or FlexTable - i want to define the Labels for the table header within the XML layout file, not programmatically within the code.

Many thanks in advance

like image 739
mr_room Avatar asked Nov 05 '22 15:11

mr_room


1 Answers

Sorry, no can do, UiBinder just doesn't support this sort of syntax. Think about it - where would this Widget go? Should it be added to the DOM tree? It also makes it hard for the compiler to tell if this code should be pruned as unused.

You'll have to wait for the GWT team to create custom tags for Grid (like they did with, for example, DockLayoutPanel). I wouldn't expect such functionality for the FlexTable though, since it's meant by design for dynamic content, meaning adding it programmatically anyway.

like image 70
Igor Klimer Avatar answered Nov 15 '22 11:11

Igor Klimer