I'm working with JSF2.1 and RichFaces 4.1 in JBoss AS 6.1.0.Final. Right now, I'm focused in rewriting the URLs. After trying different approaches I decided to stick to PrettyFaces since it's really intuitive to use (and got it working in a couple of minutes).
There's a problem tough. The relative links to scripts/css got messed up because the URLs changed and the relative paths end up in 404. I can use absolute paths but that would force me to change many of the pages and to expose application's structure in the page's source code.
I'm thinking about a temporal workaround: Giving the backing bean the responsibility of managing the different levels of those relative links but re-using beans makes this a delicate matter.
My question is, is there defined way or best practice to manage this relative paths while rewriting the URLs?
EDIT
h:outputStylesheet and h:outputScript worked like a charm. All that remains is solving a little issue with CSSs referencing images in a relative way. Take this structure:
-------/resources
|
---_img
|
---_css
|
---_js
A CSS file in the folder _css
references the image image1.png
located in the _img
folder with the relative path ../_img/image1.png
. The problem is that this ends up in 404 because it does not find the image in /myApp/javax.faces.resource/_img/image1.png
.
Changing every ../
for #{request.contextPath}/resources
inside the CSSs seems to work just fine but I wonder if there is a better way to do it. The relative path approach not working seems strange to me.