Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"This link is deactivated, because it is not embedded in a JSF form."

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?

like image 353
Aram Gevorgyan Avatar asked May 14 '11 15:05

Aram Gevorgyan


1 Answers

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:

  • When should I use h:outputLink instead of h:commandLink?
  • We don't need stinkin' faces-config
like image 71
BalusC Avatar answered Dec 09 '22 00:12

BalusC