- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 ClientBundle 和 CssResources 已经有一段时间了,但我注意到我的样式被注入(inject)了很多次。我也可以指出的一件事是我使用了很多 <ui:with field='resources' type='com.vf.client.resources.Resources' />
在我的模板中,我怀疑这是在创建我的 clientBundle 的多个副本。甚至可能导致这种情况的一件事是,我使用 Ray Ryan 的概念在我的客户端工厂中缓存我的 View ,因此一些 View 是在附加到 DOM 之前创建的。在我的基本 View 中,我在资源上使用了 provided=true 以便希望不让 UiBinder 为我生成一个新资源。虽然这可能不起作用,但我怀疑 ui:with 正在创建一个新副本并忽略提供的 = true。我已经使用 Chrome 和 Firebug 中的开发人员工具来查看,在这两种情况下,样式都被注入(inject)了很多次。如果不从我的所有 UiBinder 模板中删除我的 Resources 类,我不确定如何解决这个问题,这会带来相当多的工作。任何想法表示赞赏。
/**
*
* @author chris
*/
public abstract class ViewImpl extends Composite implements IView, RequiresResize {
@UiField(provided = true)
public final Resources resources;
}
public interface Resources extends ClientBundle, CellTable.Resources, CellList.Resources, DataGrid.Resources {
/**
* These are the obfuscated styles.
*
* @return
*/
@Source({ "default.css", "default-external.css"})
public Style style();
}
更新
我一直在使用工厂/单例来确保它只创建一个。当应用程序启动时,我在我的 ClientFactory 实现中创建了这个 Resources ClientBundle。在我的应用程序开始时,我根据自己的风格调用了 ensureEnjected,从那时起,我的代码中就再也没有调用过 ensureInjected。
这是我的工厂,它只是获取我的单例请求工厂。我曾经在我的界面中使用静态初始化器,但不久前我转向了这个,希望能解决我的多样式问题。
import com.google.gwt.core.client.GWT;
public class ResourcesFactory {
private static Resources instance = null;
private ResourcesFactory() {
}
public static final Resources getResources() {
if (instance == null) {
instance = GWT.create(Resources.class);
}
return instance;
}
}
我的客户端包仅在此处初始化和注入(inject)。
@Override
public void onModuleLoad() {
if (Window.Location.getParameterMap().containsKey("debug")) {
Window.alert("Remote Debugging will be enabled, see server log for debug information");
RemoteDebugService.enable();
}
try {
clientFactory = ClientFactory.INSTANCE;
masterLayoutPanel = clientFactory.getMasterLayoutPanel();
} catch (Exception e) {
logger.log(Level.SEVERE, "Unable to instantiate the ClientFactory", e);
Window.alert("SOMEBODY BROKE THE BUILD, add ?debug to the url to enable remote debugging" + e.getMessage());
}
RootLayoutPanel.get().add(masterLayoutPanel);
StyleInjector.inject(clientFactory.getResources().style().getText());
PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(clientFactory.getPlaceHistoryMapper());
PlaceController placeController = clientFactory.getPlaceController();
// Start PlaceHistoryHandler with our PlaceHistoryMapper
historyHandler.register(placeController, clientFactory.getEventBus(), defaultPlace);
startApplication(clientFactory, historyHandler);
}
最佳答案
多次注入(inject)到底是什么意思?
ClientBundle 基本上是 Singleton 的(请参阅此线程 Will referring to a single ClientBundle class from multiple UiBinders cost anything?)。
因此,您是否使用 provided=true
甚至都无关紧要。
但如果你真的想避免 ClientBundle 代理,你可以使用 Gin
或 Factory
来实例化(GWT.create
或神奇地通过 @Inject
) ClientBundle
一次并将其注入(inject)到您的 Views
但我猜在编译后的代码中它不会做太多区别。
关于GWT,CssStyle被多次注入(inject),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16086848/
这个问题已经有答案了: 已关闭10 年前。 Possible Duplicate: Adding css class through aspx code behind 我尝试将 css 类分配给在重写
所以我在创建这个 wordpress 主题时遇到了一个与 php 相关的问题(我认为)。 我为用户创建了一个选项面板,他们可以在其中确定主要主题颜色。为了进行测试,我将值 #008A00 放在那里。
我无法将我的 CSS 样式应用于以 html 格式发送的电子邮件。如果我将 ODS 输出保存到本地文件,我就可以应用我的 CSS 样式。 有人可以帮助我了解如何在电子邮件步骤中传递 CSS 样式吗?
我试图通过按钮单击命令以编程方式从 Panel 组件更改 CssStyle 属性“背景颜色”,但没有任何反应。如果我在 ViewModel Load() 方法上设置属性,则有效。页面加载后不会。 De
我正在尝试右对齐我的 WDG 中的一列。我已经完成了 Infragistics 教程,所以我知道我需要添加一个新的 CSS 样式... tbody > tr > td.ColumnRight {
我的 JSP 中有这个输入文本,使用的是 Bootstrap 类 但是使用 spring 标签,样式完全被忽略了! 最佳答案 我认为您需要使用 cssClass 而不是 cssStyle。 关于h
我会将我的 JSP 文件放入 HTML5 格式。 我的标签支柱单选按钮有问题; 当我放置 cssclass"disabled"(或其他类似 cssClass"red")时,当我查看源代码时,我得到了两
我是一名优秀的程序员,十分优秀!