We overrode javax.faces.application.ResourceHandlerWrapper and javax.faces.application.ResourceWrapper to load static resources, for instance css files, from the file system. How can we achieve that this resource loading mechanism also takes place for resources that are referenced in the newly loaded css file from the file system? Thanks for any help.
Add a comment |
1 Answer
Use the EL expression #{resource} in the CSS file to reference them dynamically instead of using a hardcoded path like /context/resources/someLibrary/somePath/someFile.ext or something.
E.g.
.foo { background-image: url(#{resource['someLibrary:somePath/foo.ext']}) } .bar { background-image: url(#{resource['someLibrary:bar.ext']}) } .baz { background-image: url(#{resource['somePath/baz.ext']}) } .moo { background-image: url(#{resource['moo.ext']}) } which would reference
WebContent |-- resources | |-- someLibrary | | |-- somePath | | | `-- foo.ext | | `-- bar.ext | |-- somePath | | `-- baz.ext | `-- moo.ext : This way the JSF default resource handler will substitute them with the right /javax.faces.resource URLs which will in turn go through the resource handler as well.
2 Comments
Julia
thank you. We already used the EL expression
#{resource}. I compared the spelling inside url. Ours was url("#{resource['someLibrary:somePath/foo.ext']}"). I romeved the double quotes but it didn't help.BalusC
It should work fine that way. Apparently the custom resource handler isn't doing its job entirely right. Run a debugger to investigate how it failed and then we can talk about it.