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

霸气de小男生 提交于 2019-12-30 18:26:22

问题


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?


回答1:


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



回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!