webtier@glassfish.java.net

RESTful url witj h:link

From: Serguei Cambour <s.cambour_at_gmail.com>
Date: Thu, 8 May 2014 14:38:47 +0200

I can’t figure how to achieve such a usual task as define a link to get another resource in a JSF view.
So I have the following in the view application.xhtml template page (%app_name%/src/main/webapp):

<h:link value="Posts" outcome="posts" styleClass="button"></h:link>

Here is the mapping defined in faces-config.xml:

<navigation-rule>
        <from-view-id>/index.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>posts</from-outcome>
            <to-view-id>posts/index.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <navigation-case>
            <from-outcome>home</from-outcome>
            <to-view-id>/index.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

Neverthless, when clicking on the ‘Posts’ link I’m getting then following error:

WARNING: JSF1064: Unable to find or serve resource, /posts/posts.xhtml.
May 08, 2014 2:30:36 PM com.sun.faces.renderkit.html_basic.OutcomeTargetRenderer getNavigationCase
WARNING: JSF1090: Navigation case not resolved for component j_idt16.

And the following one on then displayed page http://localhost:8080/faces/posts/index.xhtml
Posts: This link is disabled because a navigation case could not be matched.
Unable to find matching navigation case from view ID '/posts/index.xhtml' for outcome 'posts'
The posts/index.xhtml (in %app_name%/src/main/webapp/posts/) has the following content:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
<f:view>
    
    <ui:composition template="../application.xhtml">
        <ui:define name="title">JSF Blog | Posts</ui:define>

        <ui:define name="content">
            Welcome to Posts list page !
            <p>
                <h:link value="Home" outcome="home"></h:link>
            </p>
        </ui:define>

    </ui:composition>
</f:view>

</html>

What is wrong here? Why is it tryinng to map to posts/posts.xhtml ?

Thank you.