views:

76

answers:

1
<p><h:commandLink value="Apply Now" action="register" /></p>

when i writing code above, exception below throws:

[2/12/10 11:24:29:535 CST] 0000005f renderkit W Component j_id26 must be enclosed inside a form.

Is it a best practices to wrap a h:form tag in the jsf template page, and then every page using the template can just directly use the h:commandLink tag without hesitate on the h:form tag?

+3  A: 

In my opinion <h:form> and <f:view> shouldn't be in the template page, because:

  • you can't customize their attributes, like (notably: enctype or beforePhase)
  • you may want multiple forms in a page.
  • you may at some point, in some places need to replace <h:form> with <a4j:form> (for example)

If you have many, very simple pages, then you can make an alternative template, which includes the main template, and which adds <f:view> and <h:form>.

Bozho
agree, but for some case, i just want to have a simple link like the above, i still have to write below code: <p><h:form id="register"><h:commandLink value="Apply Now" action="registerUser" /></h:form></p>anyone can teach me how to style code in comment ;( ?
sunnycmf
+1 essentially for the second point. Even if you can use the `<a4j:region/>` to split your page in separate blocks - for Ajax calls.
romaintaz
Thanks all for the suggestion ;)
sunnycmf