tags:

views:

26

answers:

2

I'm trying to create a <a> tag in my Facelets XHTML page, but can't understand how to do it.. This is what I'm doing:

<h:outputLink value="static/faq.xhtml">FAQ</h:outputLink>

Am I using the right tag?

+1  A: 

Simply use <a href="static/faq.xhtml">FAQ</a>.

Bozho
You can indeed also just use "plain HTML" in Facelets, but that `f:verbatim` is unnecessary in Facelets. It's only useful to render plain HTML conditionally. This construct was only mandatory in JSF 1.0/1.1 on top of JSP, else "plain HTML" got rendered outside the component tree. According to the question history, OP is using JSF 2.0 on Facelets.
BalusC
A: 

This should work. Open page in webbrowser, rightclick and View Source to see the JSF-generated HTML output. You should see a <a> element being generated.

To learn what HTML the JSF components are rendering, head to the tag documentation. Here's a cite of relevance of the one for <h:outputLink>:

Render an HTML "a" anchor element. The value of the component is rendered as the value of the "href" attribute.

BalusC
Right, but what about my URL prefix, which is `${request.contextPath}`. It is omitted and the `<a>` is wrong.
Vincenzo
Oh, you didn't made clear in your question that you need the contextpath prefix. In future questions please elaborate the functional requirement and the problem in detail as well. How is it wrong for example. Actually, the `h:outputLink` and `h:link` are context-aware when you use a relative URL (i.e. `value` does not start with `/`, as you correctly did in your example). Also keep this in mind: relative URL's are relative to the location of the page in the request URL (as it is in browser address bar), not to the location of the page in the webcontent at webserver.
BalusC