what is request.conextPath and file structure

UI Components for JSF
Post Reply
samwun9988
Posts: 69
Joined: 22 Jan 2011, 11:04

23 Feb 2011, 23:10

Hi,

I am wondering what value does request.contextPath returns in primefaces showcase.
I found the following line of codes written in ui.xhtml file:

ui.xhtml file:

<title>PrimeFaces - ShowCase</title>
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/default.css" />
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/themes/#{guestPreferences.theme}/skin.css" />
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/syntaxhighlighter/styles/syntaxhighlighter.css" />
Should my css, themes, and templates etc folders must put under web/ folder, so that request.contextgPath returns the correct path which is "<my applicaiton context path>/", as shown below?

Code: Select all

web
   |- WEB-INF
   |- css
   |- themes
   |- templates
   |- images
   |- ui
Another question is why primefaces showcase have a faces-config.xml file but my application doesn't need one?

Very appreciate for any suggestion.
Sam.
Primefaces 2.2.1, JBOSS 6.0.0.Final, JDK1.6

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

24 Feb 2011, 14:56

To see what getContextPath does look at the API docs:

http://download.oracle.com/javaee/6/api ... textPath()

You can also just use an h:outputText component to display its value onto a page and see what it is in your particular environment.

If you are going to rely on the JSF resource loader using the concept of resource libraries you would organize your resources like:
resources/js
resources/css
resources/img
Old way of including resources from a page (if you need to control media type for example):

Code: Select all

<link type="text/css" rel="stylesheet" media="print" href="#{request.contextPath}/resources/css/print.css"/>
Or just use the JSF resource loader, for example:

Code: Select all

<h:outputStylesheet library="css" name="mystyle.css"/>
As for why you may not need a faces-config.xml - JSF uses configuration by exception, which means reasonable default values are assumed for most things and you only need to configure something if you're making an exception or doing something non-default.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests