UiBinder, can't even get to first base

389 views
Skip to first unread message

John

unread,
Jan 6, 2010, 3:04:24 PM1/6/10
to Google-We...@googlegroups.com
I thought I'd try to figure out UiBinder, but I'm lost. Played with
various tutorials and examples and finally I have striped things down
to what I believe is the bare minimum.

It started as the standard Eclipse plugin generated application, and I
have discarded virtually everything.

What's left is:

public class TestUi implements EntryPoint {

@UiTemplate("TestUi.ui.xml")
interface TestBinder extends UiBinder<VerticalPanel, TestUi> { }
private static TestBinder testBinder = GWT.create(TestBinder.class);

public void onModuleLoad() {

VerticalPanel vp = testBinder.createAndBindUi(this);
RootPanel.get().add(vp);
}
}
----------------------------------------------------------------------
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>

<ui:style>
.pretty { background-color: pink; }
</ui:style>

<g:VerticalPanel class='{style.pretty}' >
</g:VerticalPanel>

</ui:UiBinder>
-------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='testui'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>

<inherits name='com.google.gwt.user.theme.standard.Standard'/>

<!-- Other module inherits -->
<inherits name="com.google.gwt.uibinder.UiBinder" />
<!-- Specify the app entry point class. -->
<entry-point class='com.axxessible.testui.client.TestUi'/>

<!-- Specify the paths for translatable code -->
<source path='client'/>

</module>
-----------------------------------------------------------------------------
errors during compile, the lines below are in exactly the sequence shown:
Invoking com.google.gwt.dev.javac.StandardGeneratorContext@45800894
[ERROR] In <g:VerticalPanel class='{style.pretty}'>,
class VerticalPanel has no appropriate setClass() method
[ERROR] Errors in
'file:/home/john/workspace/TestUi/src/com/axxessible/testui/client/TestUi.java'
[ERROR] Line 32: Failed to resolve
'com.axxessible.testui.client.TestUi.TestBinder' via deferred binding

If I take out the class='----' out of the <g:VerticalPanel> then it
compiles. But if it's a panel widget, it should be able to set a
background-color, no?
I already know I'm doing something incredibly stupid, so I don't mind
if you skip telling me that part, and just tell me what it is!!
Thanks.

John

Arthur Kalmenson

unread,
Jan 6, 2010, 5:26:22 PM1/6/10
to google-we...@googlegroups.com
If you want to set the class name you need to use styleName or
addStyleNames instead of class.

Hope that helps.
--
Arthur Kalmenson

> --
> 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.
>
>
>
>

John

unread,
Jan 6, 2010, 7:29:07 PM1/6/10
to google-we...@googlegroups.com
On Wed, Jan 6, 2010 at 5:26 PM, Arthur Kalmenson <arthu...@gmail.com> wrote:
> If you want to set the class name you need to use styleName or
> addStyleNames instead of class.


In the older GWT versions, I know you set the stylename and used a
conventional CSS style sheet with those names.

I thought UIBinder was a whole new thing--I was trying to follow the
tutorials as closely as possible, and they inserted class=xxxx, which
is one of the standard ways of marking CSS styles, isn't it?

John

Arthur Kalmenson

unread,
Jan 6, 2010, 10:17:56 PM1/6/10
to google-we...@googlegroups.com
That's correct, but only for regular HTML Elements, not GWT widgets.
If you want to set CSS class names on GWT widgets using UI binder you
need to use the methods I mentioned.

--
Arthur Kalmenson

--

--
Arthur Kalmenson

John

unread,
Jan 7, 2010, 2:55:05 AM1/7/10
to google-we...@googlegroups.com
On Wed, Jan 6, 2010 at 10:17 PM, Arthur Kalmenson <arthu...@gmail.com> wrote:
> That's correct, but only for regular HTML Elements, not GWT widgets.
> If you want to set CSS class names on GWT widgets using UI binder you
> need to use the methods I mentioned.
>

Arthur, thanks. Someplace I saw some debate about whether UI Binder
was worthwhile. Now I see why it's in dispute.

John

unread,
Jan 7, 2010, 11:01:54 AM1/7/10
to google-we...@googlegroups.com
On Wed, Jan 6, 2010 at 10:17 PM, Arthur Kalmenson <arthu...@gmail.com> wrote:
> That's correct, but only for regular HTML Elements, not GWT widgets.
> If you want to set CSS class names on GWT widgets using UI binder you
> need to use the methods I mentioned.


Ahhhh, I finally got it. I wish I hadn't wasted so much time reading
tutorials and other "helpful" guides. The real scoop is right here:

http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/UIObject.html#setStyleName%28java.lang.String%29

Arthur Kalmenson

unread,
Jan 7, 2010, 12:18:11 PM1/7/10
to google-we...@googlegroups.com
hehe, I did mention that above.

--
Arthur Kalmenson

Reply all
Reply to author
Forward
0 new messages