8

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Aram Gevorgyan
  • 2,175
  • 7
  • 37
  • 57

2 Answers2

10

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

You need to have <h:form> wrapping the link.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140