Binding Style Fields with UiBinder

25 views
Skip to first unread message

GAbraham

unread,
Jan 6, 2010, 12:20:40 PM1/6/10
to Google Web Toolkit
I am trying to access an inline Style in a programmatic way. I have
tried following the example in the developer guide.


"From .xml file"
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>

<ui:style type='NotImportant.UserWidgetStyles'>
.test{background-color: red}

</ui:style>


<g:HorizontalPanel ui:field='listValuePanel'>
<g:Label ui:field='fName' />
<g:Label ui:field='lName' />
</g:HorizontalPanel>
</ui:UiBinder>


"From .java file"
interface UserWidgetBinder extends UiBinder<Widget,UserWidget> {}
private static UserWidgetBinder uwBinder=GWT.create
(UserWidgetBinder.class);

interface UserWidgetStyles extends CssResource{
String test();
}

@UiField Label fName;

@UiField UserWidgetStyles stylegetter;

@UiField HorizontalPanel listValuePanel;

@UiField Label lName;

The error I am getting is:
no ui:field attribute for NotImportant.UserWidget#stylegetter

I believe I have followed the example correctly. Do I need to
explicitly indicate a binding in the xml file for the stylegetter? If
so how do I do this? If not does anyone see what I am doing wrong?

Thanks for any help you can give.

-George

Thomas Broyer

unread,
Jan 7, 2010, 4:39:24 AM1/7/10
to Google Web Toolkit

Either this, or naming your field 'style', as this is the default for
<ui:style> when not explicitly set.

> If so how do I do this?

<ui:style field="stylegetter" type="NotImportant.UserWidgetStyles">

GAbraham

unread,
Jan 7, 2010, 9:10:22 AM1/7/10
to Google Web Toolkit
That solution works. Thanks for clarifying how to bind styles.

-George

Reply all
Reply to author
Forward
0 new messages