Reputation: 21
I am using jsf 2. I have a link in a facelet file that points to a external url. My current view is /app1/home.xhtml with a h:commandLink that has an action like so
<h:commandLink value="#{link}" action="#{action.redirect}" target="_blank"/>
the url that action.redirect redirects to is /app2/info.do. However it appears that JSF tries to change the extension of the url to .xhtml. and then fails with the error message.
com.sun.faces.context.FacesFileNotFoundException: /app2/info.xhtml Not Found in ExternalContext as a Resource
how do i get this to correctly redirect ?
Upvotes: 2
Views: 9526
Reputation: 1109865
Don't use the <h:commandLink>
here, it's the wrong tag for the purpose. It is designed to submit a JSF POST form and navigate to a JSF view, both which you obviously don't want to let take place in this particular use case.
Just use the <h:outputLink>
or even plain HTML <a>
. So,
<h:outputLink value="#{action.redirect}" target="_blank">#{link}</h:outputLink>
or
<a href="#{action.redirect}" target="_blank">#{link}</a>
Note that you don't need the <h:form>
in both approaches.
Upvotes: 5