we create command links on page. same command link used on different page of web site. when first created because page not have form.
scenario 1
page (no form on page)
- some text
need link. so, create command link surrounded form.
scenario 2
page b (reuse commandlink page on page b)
<h:form> text need link. so, create command link surrounded form. reuse commandlink component pagea </h:form>
throws error, inner form exception.
- cannot use h:link because of url issues.
- can use h:outputlink instead of commandlink avoid form issues?
- can create custom jsf component create commandlink. check if form exists on page. if yes, not add form. if no, add form around commandlink.
as rule, not put h:form
tags in jsf components. h:form
tag should wrap component in page you're using it, not in component itself. way you'll able mix them other components in same form providing more flexibility, @ little price of having 2 more lines of code. that's how done in public component libraries, take primefaces as example.
apart that, bear in mind h:commandlink
fires post request server, while seem talking plain links. in general, h:commandlink
used when don't know destination url @ time view renders. suggest avoid use other case, because still you've got h:link
jsf destinations , h:outputlink
external destinations, use plain html anchor element. and, definitely, firing get request doesn't require h:form
tag.
see also:
Comments
Post a Comment