ui:字段和类为/ ;单位:gwt
我正在使用 UIBinder 来制作一个小部件。
用户界面.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));
}
入口点:
public void onModuleLoad()
{
Test test = new Test();
RootPanel.get().add(test);
}
文本没有得到天蓝色.. 但是,如果我在 td 中添加一个 span 元素并执行 class="{style.back}" ,那么就可以了。 为什么?
另外,如果我尝试将 ui:field 添加到我的 td/tr 标签中,我会崩溃:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 @Chris Lercher 在评论中建议的那样,在 tr 周围添加一个表格解决了问题。结束问题..
As @Chris Lercher suggested in the comments, adding a table around the tr's solved the problem. Closing question..