0

i'm having a strange problem, if my page index.xhml is:

<html   xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">

    <head>
    //.. import css and javascript
    </head>
    <body>
    // .. my page content
    </body>
</html>

Everthing is okay, but, if i change to <head> to <h:head> and <body> to </h:body> my page it seems not apply the style very well, as far i can tell it seems my javascript file is not been applied in the page. Why this happen ? I already try change to <h:outputScript library="javascript" name="file.js" /> but it doesn't work either.

Any idea ? Why this is happening ?

5
  • 2
    How have you setup the mapping of the FacesServlet in your web.xml? I suspect you are using the wrong url to see the page. For example, if the mapping is <url-pattern>*.jsf</url-pattern> you should be using example.com/app/index.jsf to have you page parsed properly. Commented Jul 27, 2011 at 18:29
  • Hi Giorgos, my page is parsed properly, but are my javascripts that's not. Commented Jul 27, 2011 at 18:36
  • If you view the page source in the browser are the JS and CSS bits been rendered by JSF ? Commented Jul 27, 2011 at 21:35
  • 1
    Could you edit your post to include the exact syntax of your source file and the rendered page? Then we could make more informed guesses. I also suggest to use the web developer tools of Chromium. There you can check if your resources are loaded properly. Commented Jul 27, 2011 at 22:00
  • the solution to my problem is here :stackoverflow.com/questions/6928298/… Commented Aug 5, 2011 at 13:52

1 Answer 1

1

use this above body and then u can use the methods directly in your jsp

<script src="${pageContext.request.contextPath}/yourJSFile.js" type="text/javascript"/>

<link rel="stylesheet"  href="${pageContext.request.contextPath}/yourCSSFile.css"    type="text/css" />

yourJS.js yourCSS.css file should be under your WebContent(${pageContext.request.contextPath}) . Its better to maintain seperate folder for your js,css,pages etc.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.