When I use the following command link:
<h:commandLink action="student" value="students" />
And the following navigation rule in faces-config.xml
:
<navigation-rule>
<from-view-id>/home.xhtml</from-view-id>
<navigation-case>
<from-outcome>student</from-outcome>
<to-view-id>/student.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
Then I get the following development stage faces message:
This link is deactivated, because it is not embedded in a JSF form.
How is this caused and how can I solve it?
The <h:commandLink>
fires a POST request. You need to embed it in a <h:form>
.
<h:form>
<h:commandLink action="student" value="students" />
</h:form>
Since you're already on JSF 2.0, you can also just use <h:link>
instead which fires a GET request which doesn't require a form and is thus way much better for bookmarkability and SEO. Also you can get rid of the whole <navigation-rule>
since JSF 2.0 utilizes implicit navigation.
<h:link value="students" outcome="student" />
It will implicitly go to student.xhtml
.
Ensure that you're reading JSF 2.0 tutorials, not the ones targeted on JSF 1.x. In JSF 2.0 a lot of new tags and features have been added.
See also:
You need to have <h:form>
wrapping the link.
来源:https://stackoverflow.com/questions/6002884/this-link-is-deactivated-because-it-is-not-embedded-in-a-jsf-form