Hi folks Did someone have any idea how to register custom html element as GWT widget uiBinder and use them directly in place of using in HTMLPanel.
For e.g. if I'm using Google Polymer in my mgwt project I'm using custom html element as
<g:HTMLPanel >
<paper-shadow class="{style.card}">
<mgwt:touch.TouchPanel ui:field="touchPanel">
<mgwt:panel.flex.FlexPanel orientation="VERTICAL" alignment="CENTER">
<g:Image url="{global.getDirection.getSafeUri.asString}" />
<g:HTMLPanel>Take me to Deal</g:HTMLPanel>
</mgwt:panel.flex.FlexPanel>
</mgwt:touch.TouchPanel>
</paper-shadow>
</g:HTMLPanel>
I want to register/create paper-shadow as custom widget so that I can write code as so that its easy to handel events
<polymer:paper-shadow class="{style.card}">
<mgwt:touch.TouchPanel ui:field="touchPanel">
<mgwt:panel.flex.FlexPanel orientation="VERTICAL" alignment="CENTER">
<g:Image url="{global.getDirection.getSafeUri.asString}" />
<g:HTMLPanel>Take me to Deal</g:HTMLPanel>
</mgwt:panel.flex.FlexPanel>
</mgwt:touch.TouchPanel>
<polymer:paper-shadow>
I'm using and maintaining this fork of this gwt-polymer wrap.
In the test app you can see several samples of use of polymer widgets in gwt, how to wrap existing html polymer elements, how to create new ones, the use with uibinder, etc.
As far as I know, you can't easily add a new custom element that UiBinder will understand. You can add one to your custom widget, though.
You'll notice that GWT allows custom attributes on these custom elements, like in
DockLayoutPanel
:Notice the
<g:north size='5'>
element - if you look intoDockLayoutPanel
's source code, you'll see that it is handled by this method:No
@UiChild
annotation and an extra parameter means something "magical" is happening behind scenes. And true enough, there's aDockLayoutPanelParser
class that handles this special case. You'll notice that it implements theElementParser
- unfortunately, it's not possible to "plug in" your ownElementParser
.There was a project, gwt-customuibinder, that tried sidestepping this limitation, but it's been deprecated for newer (2.5+?) versions of GWT: