Custom widget with custom UiBinder markup

1,484 views
Skip to first unread message

dparish

unread,
Feb 3, 2012, 8:49:11 AM2/3/12
to Google Web Toolkit
I have a widget that would benefit from custom UiBinder markup (like
DockLayoutPanel)

I've looked through the docs, the source and the web and not found an
example of how this is implemented. Has anyone done this?

I'm looking to do something like this

<custom:mywidget ui:field="widget">
<left><!-your widget></left>
<right><!- your widget></right>
<left><!-your widget></left>
<right><!- your widget></right>
<left><!-your widget></left>
<right><!- your widget></right>
<!- your widget><!- your widget><!- your widget>
</custom:mywidget>

Jens

unread,
Feb 3, 2012, 9:09:39 AM2/3/12
to google-we...@googlegroups.com

dparish

unread,
Feb 3, 2012, 12:36:28 PM2/3/12
to Google Web Toolkit
That will work. I'd still prefer to use descriptive xml like
DocLayoutPanel. From what I see of @UiChild it just enforces the types
of children it does not allow for quite what I was looking for. (but
probably good enough)

-Dave

On Feb 3, 8:09 am, Jens <jens.nehlme...@gmail.com> wrote:
> You can use @UiChild, see:
>
> http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/googl...
>
> -- J.

dparish

unread,
Feb 3, 2012, 12:37:22 PM2/3/12
to Google Web Toolkit
I take that back. UiChild should do it perfect. Good example here:

http://stackoverflow.com/questions/8375480/gwt-custom-widget-with-child-elements-configuration-in-uibinder-like-custombutt

On Feb 3, 8:09 am, Jens <jens.nehlme...@gmail.com> wrote:
> You can use @UiChild, see:
>
> http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/googl...
>
> -- J.

Paul Stockley

unread,
Feb 3, 2012, 12:44:00 PM2/3/12
to google-we...@googlegroups.com
Add two methods

@UiChild
public void addLeft(Widget w) {...}

@UiChild
public void addRight(Widget w) {..}

Then make sure you widget implements HasWidgets or similar.

In your uibinder you can now use


<custom:mywidget ui:field="widget"> 
<custom:left><!-your widget><custom:/left>  
<custom:right><!-your widget><custom:/right> 
<!- your widget>

Steve C

unread,
Mar 4, 2014, 10:03:10 AM3/4/14
to google-we...@googlegroups.com
Some additional questions in the absence of a full dev guide:

1. What about a class that extends TabLayoutPanel?  I can write and annotate a method addTab(Widget w) in order to use the <xxx:tab> child instead of <g:tab>, but what about the grandchild <g:header> that the <g:tab> could have had?

2. Can the first parameter to the annotated method be a subclass of Widget to restrict the possible types?

Steve
Reply all
Reply to author
Forward
0 new messages