I am using UIBinder to make a widget.
ui.xml
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.back { background-color: Skyblue; }
</ui:style>
<g:HTML>
<div ui:field="somediv">
<tr class="{style.back}">
<td>The background is NOT Skyblue</td>
</tr>
</div>
</g:HTML>
</ui:UiBinder>
java
public class Test extends Composite {
interface TestUiBinder extends UiBinder<HTML, Test> {}
private static TestUiBinder uiBinder = GWT.create(TestUiBinder.class);
public Test() {
initWidget(uiBinder.createAndBindUi(this));
}
Entrypoint:
public void onModuleLoad()
{
Test test = new Test();
RootPanel.get().add(test);
}
The text does not get skyblue color..
However if i add a span element inside my td and do class=”{style.back}”, that works.
Why?
Also, if i try to add a ui:field to my td/tr tags i get a crash:
java.lang.reflect.InvocationTargetException at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396) at
com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:183) at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:5
10) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) at
java.lang.Thread.run(Unknown Source) Caused by:
com.google.gwt.core.client.JavaScriptException: (TypeError): this.removeAttribute is not a function
As @Chris Lercher suggested in the comments, adding a table around the tr’s solved the problem. Closing question..