Custom tags in UiBinder files

南笙酒味 提交于 2020-01-03 07:29:13

问题


When using a <g:LayoutPanel> in UiBinder.ui.xml files, you can specify <g:layer> tags. Some other Google-built widgets have special tags like that as well - <g:tab> even has a sub-tag, <g:header>.

How can I specify these for my own widgets?


回答1:


The new answer to this question, after some GWT improvements, is at https://stackoverflow.com/a/11785903/439317 . Copied below to avoid moderator deletion (maybe?).

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




回答2:


What you're looking for is a custom element parser for UiBinder. See this issue. Unfortunately it's not supported yet.

You might be interested in this post for some guidance on how to extend the current parser on your own.



来源:https://stackoverflow.com/questions/4083230/custom-tags-in-uibinder-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!