You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Yee CN <ye...@streamyx.com> on 2006/02/13 17:43:45 UTC
Is there a Path component in JSF
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
Re: Is there a Path component in JSF
Posted by Matthias Wessendorf <mw...@gmail.com>.
You may look at Tomahawks' stylesheet component.
It adds "FacesContext.getExternalContext().getRequestContextPath()" to
the path attribute value
HTH,
Matthias
On 2/13/06, Yee CN <ye...@streamyx.com> 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
--
Matthias Wessendorf
Zülpicher Wall 12, 239
50674 Köln
http://www.wessendorf.net
mwessendorf-at-gmail-dot-com
RE: Is there a Path component in JSF
Posted by Yee CN <ye...@streamyx.com>.
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:mkienenb@gmail.com]
Sent: Tuesday, 14 February 2006 6:20 AM
To: MyFaces Discussion; yeecn@streamyx.com
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 <ye...@streamyx.com> 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
RE: Is there a Path component in JSF
Posted by Yee CN <ye...@streamyx.com>.
Thanks Mike. 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:mkienenb@gmail.com]
Sent: Tuesday, 14 February 2006 6:20 AM
To: MyFaces Discussion; yeecn@streamyx.com
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 <ye...@streamyx.com> 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
Re: Is there a Path component in JSF
Posted by Mike Kienenberger <mk...@gmail.com>.
#{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 <ye...@streamyx.com> 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