Facelets Tips

Monday, 16 May 2011 12:02

Facelets tips

1) Always use head and Body JSF tags

You should never use <head or <body> html tags directly in your facelets file. use :

html Java server faces
<head></head> <h:head></h:head>

<body></body>

<h:body></h:body>

Java Server faces use the jsf tags to find the correponding regions.

Several components are using those tags :

  • <f:ajax> use the head tag to insert the javascripts and will not be able to place the file if the tags are missing
  • <h:outputStyleshee> need the head to create the css links
  • <h:outputScript> need to create script reference in the head region

2) Don't hardcode urls to internal resources

To prevent link error it is a good practive to use relative url or use�#{request.contextPath} expression to reference resources

Tags: java , create , server , faces , facelets , head , body , tags , tips , reference , resources

Add comment


Security code
Refresh