JSF h:outputStylesheet转换器-动态CSS? [英] JSF h:outputStylesheet converter - dynamic css?

查看:141
本文介绍了JSF h:outputStylesheet转换器-动态CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现<h:outputStylesheet/>具有转换器属性.将虚拟(直通)转换器连接到该转换器后,什么也没发生.经过仔细检查,尽管按下了浏览器刷新按钮,但似乎甚至没有调用该转换器.

I just noticed <h:outputStylesheet/> has a converter attribute. After attaching a dummy (pass-through) converter to it, nothing happened. On closer inspection, it seems the converter isn't even called despite hitting the browser refresh button.

此属性对任何事物都有用吗?仅仅是各种设计决策的副作用吗?

Is this attribute good for anything? Is it just there as a side effect of various design decisions?

我问的原因是,最好使用更少来执行一些客户端或服务器端的CSS处理.或类似的内容,我认为该属性可能会有所帮助.

The reason I ask is that it would be nice to perform some client- or server-side css processing with less or similar and I thought this attribute might help.

推荐答案

此属性对任何事物都有用吗?仅仅是各种设计决策的副作用吗?

这确实是设计使然",因为该组件扩展了 UIOutput .实际上,它并没有使用转换器.

That's indeed "by design" since the component extends UIOutput. It does indeed not use the converter for anything.

我问的原因是,用更少或相似的时间执行一些客户端或服务器端的CSS处理会很好,我认为此属性可能会有所帮助.

您可以在<h:outputStylesheet>加载的CSS资源中按常规方式使用EL.最初执行此操作是为了正确解析背景图像资源.

You can just use EL the usual way in CSS resources loaded by <h:outputStylesheet>. This was initially implemented in order to resolve background image resources properly.

.some {
    background-image: url(#{resource[images/some.png]});
}

以上示例假定图像位于/resources/images/some.png中.如果您使用的是库,则需要在资源名称前添加libraryname:.

The above example assumes the image to be in /resources/images/some.png. If you're using a library, you need to prefix the resource name with libraryname:.

.some {
    background-image: url(#{resource[somelibrary:images/some.png]});
}

假设图片位于/resources/somelibrary/images/some.png中.

但是除此之外,您基本上可以将CSS资源中的EL用于其他任何内容.例如.动态解析颜色,字体等.

But other than that, you could basically use EL in the CSS resource for anything else. E.g. dynamically resolving colors, fonts and so on.

.some {
    color: #{theme.color};
    font: #{theme.font};
}

#{theme}可以是会话,也可以是应用程序范围的托管Bean.

Where #{theme} can be a session or maybe application scoped managed bean.

这篇关于JSF h:outputStylesheet转换器-动态CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆