【发布时间】:2010-04-05 15:08:46
【问题描述】:
我正在使用 UIBinder 和 MVP 编写 GWT 小部件。小部件的默认样式在 TheWidgetView.ui.xml 中定义:
<ui:style type="com.widgetlib.spinner.display.TheWidgetView.MyStyle">
.textbox {
border: 1px solid #red;
}
.important {
font-weight: bold;
}
</ui:style>
小部件的 CssResource 接口在 TheWidgetView.java 中定义:
public class TheWidgetView extends HorizontalPanel implements TheWidgetPresenter.Display {
// ... some code
@UiField MyStyle style;
public interface MyStyle extends CssResource {
String textbox();
String important();
}
// ... more code
}
我希望这个小部件的使用者能够自定义小部件的部分样式并将其包含在他们的 MyExample.ui.xml 中:
<ui:style type="com.consumer.MyExample.MyStyle">
.textbox {
border: 2px solid #black;
}
</ui:style>
这就是他们的MyExample.java:
public class MyExample extends Composite {
// ... some code
@UiField MyStyle style;
interface MyStyle extends TheWidgetView.MyStyle{
String textbox();
}
// ... more code
}
有没有一种方法可以让我的小部件具有默认样式,但小部件的使用者可以覆盖其中一个?当接口扩展 TheWidgetView.MyStyle 时,小部件使用者需要定义该父接口中列出的所有样式。我已经看到一些小部件库有小部件的构造函数以 ClientBundle 作为参数,我想它可以应用于 CssResource。虽然,我不确定如何在 UIBinder 调用的构造函数中传递此样式对象。
非常感谢!
【问题讨论】:
-
有人用过 CssResource '@eval' 吗?这可能有用吗?
-
这似乎不适用于 UIBinder/MVP googlewebtoolkit.blogspot.com/2008/12/…
标签: gwt mvp uibinder cssresource