{"id":1215,"date":"2011-02-11T17:49:07","date_gmt":"2011-02-11T17:49:07","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=1215"},"modified":"2011-06-20T12:22:37","modified_gmt":"2011-06-20T12:22:37","slug":"houtputstylesheet-issues","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=1215","title":{"rendered":"Further h:outputStylesheet issues"},"content":{"rendered":"<p>I needed to load a custom style sheet for a composite component.<\/p>\n<p>Primefaces has problems loading theme images correctly when using h:outputStylesheet as per <a href=\"http:\/\/salientsoft.co.uk\/?p=1026\"><strong>here<\/strong><\/a>, but using a raw link tag was no good as I wanted to develop a custom component which loaded its own styles, i.e. it had no &lt;head&gt; section.<\/p>\n<p><a href=\"http:\/\/primefaces.prime.com.tr\/forum\/viewtopic.php?f=3&amp;t=5642&amp;p=24002&amp;hilit=outputStylesheet#p24002\"><strong>This post here<\/strong><\/a> indicates that if you don\u2019t use the <em>library<\/em> attribute you can get h:outputStylesheet to work even with Primefaces themes.<\/p>\n<p>In my case, I was not loading themes\/images etc. so this was not an issue, but I still used the following directive and avoided use of the <em>library<\/em> attribute for simplicity:-<\/p>\n<blockquote><p><em>&lt;h:outputStylesheet name=&#8221;uk.co.salientsoft\/util\/SSBreadcrumb.css&#8221;\/&gt;<\/em><\/p><\/blockquote>\n<p>This version worked. My initial attempts (which failed with a resource loading error) were as follows :-<\/p>\n<blockquote><p><em>&lt;h:outputStylesheet name=&#8221;resources\/uk.co.salientsoft\/util\/SSBreadcrumb.css&#8221;\/&gt;<\/em><\/p>\n<p><em>&lt;h:outputStylesheet name=&#8221;#{request.contextPath}\/resources\/uk.co.salientsoft\/util\/SSBreadcrumb.css&#8221;\/&gt;<\/em><\/p><\/blockquote>\n<p>In other words, with a css file stored in Eclipse under WebContent\/resources\/uk.co.salientsoft\/util\/SSBreadcrumb.css,\u00a0 the above working example was correct, <strong>i.e. to load correctly, omit the context root and the <em>resources<\/em> level and use a relative reference without the preceding slash.<\/strong><\/p>\n<p>I did try to debug this by visiting the <em>logger settings <\/em>in Glassfish admin, then under the <em>Log Levels<\/em> tab, setting everything with JSF in it to finest! This did display an error when trying to load the resource:-<\/p>\n<blockquote><p><em>[#|2011-02-11T17:21:13.331+0000|FINE|glassfish3.0.1|javax.enterprise.resource.webcontainer.jsf.application|_ThreadID=31;_ThreadName=Thread-1;<br \/>\n<\/em><em>ClassName=com.sun.faces.application.resource.ResourceHandlerImpl;MethodName=logMissingResource;<br \/>\n|JSF1064: Unable to find or serve resource, \/SSBreadcrumb\/resources\/uk.co.salientsoft\/util\/SSBreadcrumb.css.|#]<\/em><\/p><\/blockquote>\n<p>However the error was not particularly informative as it just spat back to me the path I gave it to load. It would have been nice for it to tell me how it was mapping the path as then I could have seen the problem more easily.<\/p>\n<p><strong>Note however<\/strong> that using this page in Glassfish is a very convenient way to turn on logging in Glassfish, as it lists the common logger paths for you and gives a combo to select the level for each. You don\u2019t have to go googling for the logger paths and edit a log properties file yourself. <strong>Note also<\/strong> that when you do this you must restart Glassfish for the log level changes to actually take effect.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed to load a custom style sheet for a composite component. Primefaces has problems loading theme images correctly when using h:outputStylesheet as per here, but using a raw link tag was no good as I wanted to develop a custom component which loaded its own styles, i.e. it had no &lt;head&gt; section. This post [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[189,76,10,40,184,101,112,16],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1215"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1215"}],"version-history":[{"count":6,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1215\/revisions"}],"predecessor-version":[{"id":1388,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1215\/revisions\/1388"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}