webtier@glassfish.java.net

Re: RESTful url witj h:link

From: John Yeary <johnyeary_at_gmail.com>
Date: Thu, 8 May 2014 08:51:27 -0400

The outcome is related to JSF navigation. There are NavigationCase objects
that represent JSF outcomes. The outcome in this case is not JSF, so it is
not in the NavigationHandler. Simply put, you can not do this by default.

You can create an instance of ConfigurableNavigationHandler and register
it. In the handler you can provide custom navigation to your REST resource.

John

____________________________

John Yeary
____________________________
*NetBeans Dream Team*


*President Greenville Java Users GroupJava Users Groups Community
LeaderJava Enterprise Community Leader*

____________________________

<http://javaevangelist.blogspot.com/> <https://twitter.com/jyeary>
<http://www.youtube.com/johnyeary>
  <http://www.linkedin.com/in/jyeary>
<https://plus.google.com/112146428878473069965>
  <http://www.facebook.com/jyeary>
<http://feeds.feedburner.com/JavaEvangelistJohnYearysBlog>
  <http://netbeans.org/people/84414-jyeary>

"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
-- Theodore Roosevelt


On Thu, May 8, 2014 at 8:38 AM, Serguei Cambour <s.cambour_at_gmail.com> wrote:

> 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.
>