【发布时间】:2010-11-15 10:42:45
【问题描述】:
我想使用 .
在多个小部件之间共享一个 CSS。我可以看到 css 类名被混淆了,但是类定义 当我检查 firefox / chrome 中的元素时没有出现。 这是我的代码。谁能建议我错过了什么?谢谢。
样式.css
.nameSpan { color: #3E6D8E; background-color: #E0EAF1;}
资源.java
public interface Resources extends ClientBundle {
@Source("Style.css")
Style style();
public interface Style extends CssResource {
String nameSpan();
}
}
uibinder.ui.xml
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field='res' type='com.my.app.widgets.logoname.Resources'/>
<g:HTMLPanel>
<div>
Well hello there
<g:InlineLabel ui:field='nameSpan' styleName="res.style.nameSpan">kevin</g:InlineLabel>
</div>
</g:HTMLPanel>
</ui:UiBinder>
uibinder.class
public class uibinder extends Composite {
private static uibinderUiBinder uiBinder = GWT.create(uibinderUiBinder.class);
interface uibinderUiBinder extends UiBinder<Widget, uibinder> {}
@UiField(provided = true) final Resources res; // the style doesn't show no matter provided=true is declared or not.
public uibinder(Resources res) {
res = GWT.create(Resources.class);
initWidget(uiBinder.createAndBindUi(this));
}
【问题讨论】:
-
别忘了致电:
res.style().ensureInjected(); -
是的,这就是解决方案!!!谢谢。你应该把它作为答案,我会接受它!