Theory behind UiBinder that makes TabLayoutPanel work

50 views
Skip to first unread message

kornhill

unread,
Jun 22, 2010, 1:05:52 AM6/22/10
to Google Web Toolkit
Given the absence of a vertical TabLayoutPanel in GWT, I was trying to
patch the TabLayoutPanel code in my local space by copying the
TabLayoutPanel source code and modifying it. However, when I use
UiBinder to construct my UI, I run into a problem that makes me wonder
how UiBinder works behind the scene.

First I have my locally modified TabLayoutPanel class, which I name it
"MyTabLayoutPanel".
Then I use it in a UiBinder template like this:
...
<g:MyTabLayoutPanel barUnit='PX' barHeight='35' ....>
<g:tab>
<g:header size='7'>ABC</g:header>
<g:Label>This is a test</g:Label>
</g:tab>
...
</g:MyTabLayoutPanel>

When running the program, I ran into the following issues:
- "Class MyTabLayoutPanel has no appropriate setBarUnit method... "
- "tab" not found, obviously UiBinder doesn't recognize the "<g:tab>"
thing

If I switch "MyTabLayoutPanel" back to the standard "TabLayoutPanel",
everything works. In fact, to trouble-shoot my problem, I merely copy
the original GWT TabLayoutPanel to my app code space and rename it
"MyTabLayoutPanel" without any other modification.

When I look at TabLayoutPanel code, I notice the constructor takes a
"barUnit" and a "barHeight" as arguments. I wonder why widgets in
GWT's own SDK do not need to follow the rule of providing an empty
constructor or using things like "@UiConstructor". Also, if I want to
natively write my own widget to support things like "<g:tab>",
"<g:cell>" etc in UiBinder, how should I do it?

Any advices would be highly appreciated.

Chris Boertien

unread,
Jun 22, 2010, 2:37:23 AM6/22/10
to google-we...@googlegroups.com
I'm only just starting to dive into GWT internals but I believe to do
this you will need to create a Parser for your widget to be recognized
internally by UiBinder.

http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/uibinder/elementparsers/TabLayoutPanelParser.java

The method error your getting is from the fact that GWT is magically
trying to map the attribute which it has failed to deal with in any
meaningful way to a method in your class which of course doesn't
exist. You'll notice within that parser that barHeight and barUnit are
being consumed by the parser.

And of course the rest of the parser is about dealing with the child
tags that it supports as special.

> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

kornhill

unread,
Jun 22, 2010, 5:30:58 AM6/22/10
to Google Web Toolkit
superb! that's helpful info. thanks a whole lot.

your response leads me to custom element parsers, which prompts me to
try figuring out how to register one of my own. and i find one
discussion here - http://groups.google.com/group/google-web-toolkit-contributors/browse_thread/thread/4d79f729030527c5
; and i find relevant code here:
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java

the above is a bit discouraging because it shows that there is no
easy, documented (and probably finalized) way of making a "native
widget" leveraging existing UiBinder facilities, even with GWT 2.1.


On Jun 22, 2:37 pm, Chris Boertien <chris.boert...@gmail.com> wrote:
> I'm only just starting to dive into GWT internals but I believe to do
> this you will need to create a Parser for your widget to be recognized
> internally by UiBinder.
>
> http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/...
>
> The method error your getting is from the fact that GWT is magically
> trying to map the attribute which it has failed to deal with in any
> meaningful way to a method in your class which of course doesn't
> exist. You'll notice within that parser that barHeight and barUnit are
> being consumed by the parser.
>
> And of course the rest of the parser is about dealing with the child
> tags that it supports as special.
>
Reply all
Reply to author
Forward
0 new messages