问题
Trying to extend AbsolutePanel, my UiBinder won't allow the <g:at>
element which is normally ok for straight AbsolutePanels. How do I make my AbsolutePanel subclass able to use the <g:at>
element? And more generally, can I make custom UiBinder keywords for my own custom Widgets like "at", "west", "layer" etc.?
回答1:
You can use @UiChild to declare special functions in your widgets accessible in UiBinders.
for example,
class MyPanel extends AbsolutePanel {
@UiChild
public void addAt(Widget w, String parameter1, String parameter2) {
....
Then, in your uiBinder, you can say
<custom:MyPanel>
<custom:at parameter1="HI" parameter2="Anything you like!">
<g:AnySingleWidget />
</custom:at>
</custom:MyPanel>
See @UiChild at http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/uibinder/client/UiChild.html
来源:https://stackoverflow.com/questions/11782171/gwt-uibinder-how-to-make-a-custom-absolutepanel-which-uses-the-at-element