0

i'm with a problem, if i use:

<head> .. stylesheet and javascripts </head> 

My style from stylesheet is all right, but with an alert in the bottom: "One or more resources have the fate of 'head', but no component of 'head' was defined in the view."

so if i change <head> by <h:head> the warning disappear but my style gone too..

what is the problem ?

UPDATE:

// index.xhtml <head> <ui:include src="jsf/components/head_index.xhtml" id="head" /> </head> <h:body styleClass="nojs"> ... </h:body> // head_index.xhtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <link rel="shortcut icon" href="#{request.contextPath}/images/logo.ico" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta name="robots" content="index, follow" /> <meta name="keywords" content="" /> <meta name="title" content="" /> <meta name="description" content="" /> <title>TITLE</title> <!-- ////////////////////////////////// --> <!-- // Start Stylesheets // --> <!-- ////////////////////////////////// --> <link href="./css/style.css" rel="stylesheet" type="text/css" /> <link href="./css/nivo-slider.css" rel="stylesheet" type="text/css" media="screen" /> <!-- ////////////////////////////////// --> <!-- // Javascript Files // --> <!-- ////////////////////////////////// --> <script type="text/javascript" src="./js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="./js/cufon-yui.js"></script> <script type="text/javascript" src="./js/geosanslight_500.font.js"></script> <script type="text/javascript"> Cufon.replace('h1') ('h2') ('h3') ('h4') ('h5') ('h6') ('.middle-text'); </script> <script type="text/javascript" src="./js/jquery.lavalamp.js"></script> <script type="text/javascript" src="./js/jquery.easing.1.1.js"></script> <script type="text/javascript"> var $ = jQuery.noConflict(); $(document).ready(function(){ /* Function for lavalamp navigation menu and dropdown */ $("#menu").lavaLamp({ fx: "backout", speed: 700 }); $(" #menu ul ").css({display: "none"}); // Opera Fix $(" #menu li").hover(function(){ $(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(400); },function(){ $(this).find('ul:first').css({visibility: "hidden"}); }); /* if javascript disabled */ $("body").removeClass("nojs").addClass("js"); }); </script> <script type="text/javascript" src="./js/jquery.nivo.slider.pack.js"></script> <script type="text/javascript"> /* homepage slideshow */ $(window).load(function() { $('#slider').nivoSlider({ effect:'random', //Specify sets like: 'fold,fade,sliceDown' slices:15, animSpeed:500, //Slide transition speed pauseTime:6000, directionNav:false, //Next &amp; Prev startSlide:0 //Set starting Slide (0 index) }); }); </script> <!--[if lte IE 8]> <script type="text/javascript" src="http://demo.templatesquare.com/html/genesis/genesis-default/js/DD_roundies_0.0.2a-min.js"></script> <script type="text/javascript" src="http://demo.templatesquare.com/html/genesis/genesis-default/js/ie_rounded_config.js"></script> <![endif]--> </ui:composition> //top <div id="top"> <div id="topleft"> <div id="logo"> <h1><a href="./index.xhtml">PROJECT</a></h1> </div><!-- end #logo --> </div><!-- end #topleft --> 

UPDATE 2: i'm trying the @Vineet and @George suggestion, but i'm with a trouble: This works :

<link href="#{request.contextPath}/css/style.css" rel="styleSheet" type="text/css"/> 

But when i try to use in JSF like:

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

The structure of the folder is:

WebPages META-INF WEB-INF css html images js jsf ..// .xhtml files 

It doesn't work...

Any idea guys ?

Best regards, Valter Henrique.

10
  • 1
    Statements like but with an alert in the bottom are very obtuse. Where does this error appear? Does it appear in the browser, or in the server logs or elsewhere? Also, would I be right in assuming that the statement the warning disappear but my style gone too, would be interpreted as the warning has disappeared but my style is not present in the HTML document? Commented Jun 19, 2011 at 13:02
  • @Vineet, the error appears in the bottom of the html page, in the browser. i think the warning is generated automatically by the jsf compiler, my guess. Commented Jun 19, 2011 at 13:20
  • Are you running the application in the Development mode? If not, I would suggest doing so, so that you can take a look at the component tree in the event of an error. Commented Jun 19, 2011 at 13:29
  • Also, do take a look at the facelet tag library docs for h:outputScript and h:outputStyleSheet. I suspect you haven't used them correctly. Posting your code would help in understanding the problem better. Commented Jun 19, 2011 at 13:30
  • @Vinnet, i update my post, i'm showing how i'm including the stylesheet and the javascript. Commented Jun 19, 2011 at 13:38

1 Answer 1

4

You should use #{request.contextPath} to point absolute app location. If your scripts located in js folder of your app, you can use

<script type="text/javascript" src="#{request.contextPath}/js/jquery.lavalamp.js"/> 

or h:outputScript and h:outputStyleSheet as @Vineet Reynolds suggested

UPDATE:
if you want to use h:outputStyleSheet you should create resources folder in WebPages and copy css and js folder in it. So the structure of the folder will be

WebPages META-INF WEB-INF resources css js html images jsf ..// .xhtml files 

then you can use h:outputStyleSheet such way :

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

and for javascript

<h:outputScript library="js" name="somejs.js"/> 

For more details about packaging resources in jsf 2 look at this post

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.