Try #{request.contextPath}
Lincoln Baxter III
On Nov 12, 2009 1:23 PM, <webtier_at_javadesktop.org> wrote:
For some followup, I can get context-relative paths in h:graphicImage by
just starting the URLs with a /. For example,
<h:graphicImage url="/images/foo.gif"/>
gets rendered as
<img src="/my-context-path/images/foo.gif"/>
Or, as I said before, I can put the images in "resources" and use the
"library" attribute of h:graphicImage. And, for scripts, I see the benefits
of the h: tags, since multiple calls to h:outputScript still result in the
JS file being loaded only once. And, you can put the call to h:outputScript
anywhere in the page. This lets components make use of JS files without
having to worry about whether the file is already loaded. Similarly, if a
component needs a specific style sheet, it is nice that it can do
h:outputStyleSheet without worrying if the file is already loaded or needing
to put the tag in the head section.
But, I still can't see how to do context-relative paths for simple hypertext
links. I can't find an option for this in h:outputLink. So, I have been
doing this kludgy hack:
A) Define an application-scoped bean named Context with a getPath method
that spits out the context path.
B) Using this in the template files:
<a href="#{context.path}/foo.jsf">
(Again, the point is that I have templates that are used by pages in
different subfolders, and I need the relative URLs to come out right.)
There is nothing horrible about this, but since there is a builtin way to
handle this issue for style sheets, images, and scripts, I suspect I am
still missing the builtin way to handle it for regular hypertext links. Any
clues for me?
Cheers- - Marty JSF 2.0 Tutorial:
http://www.coreservlets.com/JSF-Tutorial/jsf2/
[Message sent by forum member 'martyhall' ]
http://forums.java.net/jive/thread.jspa?messageID=371598
--------------------------------------------------------------------- To
unsubscribe, e-mail: webti...