0

I am having this problem which I don't know how to fix. When I run the project, the CSS displays correctly on the XHTML page but as soon as I click on a link to the same page/another XHTML page, the CSS disappears.

However, I also have a JSP page in my project and when I click on the same link for the JSP page, the CSS still works perfect but doesn't if I click on a XHTML.

I can this be fix so that the CSS will always appear on all the XHTML page like the JSP page?

XHTML CSS Link

<h:outputStylesheet name="style.css" library="css"/>

JSP CSS Link

 <link rel="stylesheet" type="text/css" href="resources/css/style.css"> 
Jacob G
  • 13,762
  • 3
  • 47
  • 67
  • Does that link point to an URL which matches the `` of the `FacesServlet`? Differently put: when you click that link and then do rightclick, view source on that page in webbrowser, do you see the raw XHTML source code or its generated HTML output? If you're still seeing raw XHTML source code in there, then the way how you're creating links is wrong, or the way how you configured `FacesServlet` is wrong. – BalusC Apr 15 '15 at 20:20
  • I don't understand. this is what I found. /faces/* – user4591082 Apr 15 '15 at 20:28
  • Open the working XHTML page in webbrowser. Click the link until CSS disappears. On that page, rightclick in webbrowser and choose *View Source*. Look closer. Do you see a `` or a `` in there in place where you originally declared the `` in the XHTML source code? – BalusC Apr 15 '15 at 20:31
  • As I guessed. Your question is answered in the duplicate. By the way, also do rightclick and *View Source* on the working XHTML page. Hopefully you'll at that point realize that JSF is just a HTML code generator based on XHTML templates and that webbrowsers doesn't understand XHTML at all. Other food for read: http://stackoverflow.com/tags/xhtml/info – BalusC Apr 15 '15 at 20:35
  • Ok. I understand. I checked the working XHTML page and get a – user4591082 Apr 15 '15 at 20:40
  • I changed my url-pattern to *.xhtml but when I run the project, i get this error: "/faces/index.xhtml Not Found in ExternalContext as a Resource" – user4591082 Apr 15 '15 at 20:50
  • Just get rid of `/faces` in URL. Try reading the duplicate (and the links therein) more carefully. Perhaps it's better to take a complete JSF pause and start learning some prerequired basics first ([HTTP, Servlets, HTML, etc](https://jsf.zeef.com/bauke.scholtz#block_20996_before-learning-jsf)). – BalusC Apr 16 '15 at 06:52
  • Ok. Done it. Completely resolved. Thank You. I definitely need to read up. – user4591082 Apr 16 '15 at 10:44

0 Answers0