Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include CSS relative to context path in JSF 1.x?

Tags:

jsf

How can I include CSS stylesheets relative to context path in JSF 1.1?

<link href="{CONTEXT}/css/style.css" rel="stylesheet" type="text/css"/>

Like we use in JSF2.

<link href="#{resource['css:styles.css']}" rel="stylesheet" type="text/css"/>
like image 952
Tarun Nagpal Avatar asked Aug 23 '11 14:08

Tarun Nagpal


1 Answers

Depends on the view technology being used:

If JSP(X), use ${pageContext.request.contextPath}:

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

If Facelets 1.x, use #{facesContext.externalContext.requestContextPath}:

<link href="#{facesContext.externalContext.requestContextPath}/css/style.css" rel="stylesheet" type="text/css"/>

If Facelets 2.x, use #{request.contextPath}:

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

Note that there's no support for #{resource} nor <h:outputStylesheet> in JSF 1.x.

like image 123
BalusC Avatar answered Nov 15 '22 08:11

BalusC