0

In html it is working perfectly , but I'm guessing it's not the same for a JSF file. I'm trying to change the background color of body, to have a background color for my webPage but it doesn't seem to work, Here is my code:

<?xml version="1.0" encoding="UTF-8"?>

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255"/>
<title>Welcome</title>
</h:head>
<h:body style="background-color:blue;">

</h:body>
</html>
Dani Gilboa
  • 599
  • 4
  • 13
  • 30

4 Answers4

2

instead of using inline CSS style you can define your style for body tag

body { 
    background-color:blue; 
}
muneebShabbir
  • 2,500
  • 4
  • 29
  • 46
1

You need to make sure that the request URL as you see in the browser's address bar matches the <url-pattern> of the FacesServlet as you've configured in your web.xml. Otherwise the JSF tags won't be parsed and won't produce the desired HTML output. You can confirm this by doing rightclick and View Source in webbrowser. Instead of <body> the webbrowser would receive a <h:body> which it doesn't understand. You should not be seeing any JSF tags over there but instead its generated HTML output.

Imagine that it is <url-pattern>*.jsf</url-pattern>, then you should be opening the page as http://example.com/context/page.jsf instead of http://example.com/context/page.xhtml.

Otherwise, you'd better change the <url-pattern> to *.xhtml so that you never need to fiddle with virtual URLs.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
0

You have an empty page that results in an empty body which is not displayed. Either put something in your body or change the style to:

style="width: 100%; height: 100%;background-color:blue;"
Lukas Eichler
  • 5,689
  • 1
  • 24
  • 43
0

You can use the following jQuery code to change the colour of the body tag.(it works)

Actually your page is being added within another body tag... so by changing the body, you are not changing the real body's attributes.

JQuery helps you in almost everything.

$( document ).ready(function() { $('body').css('background', 'blue'); });

Ch Faizan Mustansar
  • 354
  • 3
  • 6
  • 18