Thanks. That does the trick.
I also found out that it is much more convenient to have the following:
<head>
<base href="#{utilBean.basePath}" />
</head>
After that all path will be resolved relative to the basePath, saving quite
a bit of typing. For example:
<img src="images/logo.bmp" />
Best regards,
Yee
-----Original Message-----
From: Mike Kienenberger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 14 February 2006 6:20 AM
To: MyFaces Discussion; [EMAIL PROTECTED]
Subject: Re: Is there a Path component in JSF
#{facesContext.externalContext.requestContextPath} for
request.getContextPath().
You could probably get the rest using
#{facesContext.externalContext.request.scheme} and so on.
However, you're probably better off writing a backing bean to do all
of this for you so you keep all of the logic out of your pages.
#{basePathBackingBean.basePath} which computes and returns the value of
String basePath = request.getScheme() + "://" +
request.getServerName() + ":" + request.getServerPort() +
request.getContextPath() + "/";
You could also do it by defining a facelets function.
Or you could create a custom component that does all of this, and
that'd work for facelets or jsp.
-Mike
On 2/13/06, Yee CN <[EMAIL PROTECTED]> wrote:
>
>
>
> Hi,
>
>
>
> Is there a JSF component for base path? I like to achieve the equivalence
of
> the following:
>
>
>
> <% String basePath = request.getScheme() + "://" + request.getServerName()
+
>
> ":" + request.getServerPort() + request.getContextPath() + "/";%>
>
>
>
> <link href="<%=basePath%>styles/basic.css" rel="stylesheet"
> type="text/css" />
>
>
>
> I am migrating to facelets and I need to find an equivalent to the above
as
> relative path won't work because JSF navigation leaves the URL one step
> behind the actual URL.
>
>
>
> Or is there an alternate to this?
>
>
>
>
>
> Many thanks in advance,
>
>
>
> Best Regards,
>
> Yee