• Post Reply Bookmark Topic Watch Topic
  • New Topic

load images from css on composite component  RSS feed

 
Nicola Camuffo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i have an issue about loading images from css using a composite component. The folder structure is:

resources
resources -> css -> componentname
resources -> images - > componentname
resources -> WEB-INF


If i write in the css something like



or



i have a 404 error and i can't see the image.

I able to load the image only if i write path with context-root:



but i can't write explicit context root in css files!!

So, i tried to use resource EL variable:



but this last way render



and i not able to replicate the right way written above.


The project is developed with RSA9 and WebSphere Portal 8, but if i try to execute it in NetBeans (no portal) it run correctly!!

Is there a portal problem? Or a portal+JSF problem?


Thanks!!


 
Tim Holloway
Bartender
Posts: 18554
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a relative path problem, and yes, the relative URL paths are probably different in a portlet than in a stand-alone webapp.

JSF2 has a special outputStyleSheet tag that gets around the path issues as well as supporting "skinning" of CSS via an appropriate resource directory structure. For JSF1, you'd have to do things the hard way.
 
Nicola Camuffo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using JSF 2.0 but... i have to load images from css!

The outputStyleSheet tag can only be used in page files (xhtml or jsp).

 
Tim Holloway
Bartender
Posts: 18554
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're just going to have to code the absolute URL if you cannot get the image reference in a JSF View Template (xhtml). CSS in its current incarnation doesn't permit variable substitution, so the only way to get a CSS page to have a variable URL would be to run it through a servlet that modified the outgoing CSS text.

CSS handling in JSF isn't any different than CSS in non-JSF J2EE. Unless you define an alternative resource source as part of your application program logic, the css file will copied verbatim to the HTTP response stream by the webapp server's built-in default servlet.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!