简体   繁体   English

使用Wicket在CSS中引用图像

[英]Image referencing in CSS with Wicket

Per a great answer from another question I have begun mounting global resources (css/js/images) in the init() method of my WebApplication. 根据另一个问题的一个很好的答案,我已经开始在我的WebApplication的init()方法中安装全局资源(css / js / images)。 Using the following: 使用以下内容:

mountSharedResource("/images/edit-btn.gif", new ResourceReference(GlobalResource.class, "edit-btn.gif").getSharedResourceKey());

This of course allows css in another package to do something like this: 这当然允许另一个包中的css做这样的事情:

background-image: url("/images/edit-btn.gif");

The problem I have run into is that this only works at runtime, the mounted path is virtual. 我遇到的问题是这只能在运行时工作,挂载的路径是虚拟的。 One of the big benefits of Wicket (imo) were the features ( <wicket:remove> , xml valid tags, head links, page inheritance) which allowed a page designer working with layout to be able to visualize the page with its images, js, css, etc without having to run within the wicket engine. Wicket(imo)的一大好处是功能( <wicket:remove> ,xml有效标签,头部链接,页面继承),它允许使用布局的页面设计者能够使用其图像js可视化页面。 ,css等,而不必在wicket引擎内运行。

I am totally acceptant of the fact there is never a clear line between the designer/programmer roles in Web apps, but it seems odd to me the Wicket designers missed this. 我完全接受Web应用程序中的设计人员/程序员角色之间从未有过明确界限的事实,但Wicket设计师错过了这一点似乎很奇怪。 Is there any way to allow a globally used image to render stand-alone as well as work at runtime in Wicket? 有没有办法允许全局使用的图像独立呈现以及在Wicket中运行时工作?

I think the recommended way is to take html from your designers and turn in into wicket components - which means you'll split it into several files. 我认为推荐的方法是从你的设计师那里获取html并转入wicket组件 - 这意味着你将它分成几个文件。 Rendering those partial files won't work without any extra efforts. 如果不做任何额外的努力,渲染这些部分文件将无法工作。 I'd recommend to setup a simple script, tool or anything along those lines that will start your webapp for your designers to work on. 我建议您设置一个简单的脚本,工具或其他任何可以启动您的webapp以供设计人员使用的工具。 This way, they can modify the fragments and immediately see the updated rendering. 这样,他们可以修改片段并立即看到更新的渲染。 You'll have to agree on a common structure and tell them how to use the <wicket:remove> and you should be fine. 你必须就一个共同的结构达成一致并告诉他们如何使用<wicket:remove>你应该没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM