问题描述
我们正在使用JSF-2.1.7并以所有形式发布请求.我试图证明是使用<h:commandButton>
还是<h:commandLink>
.可以使用样式和jQuery控制<h:commandLink>
(href <a/>
)的外观.
We are using JSF-2.1.7 and in all our form post requests. I am trying to justify whether to use <h:commandButton>
or <h:commandLink>
. The appearance of <h:commandLink>
(href <a/>
) can be controlled using style and jQuery.
推荐使用哪个<h:commandButton>
或<h:commandLink>
?有什么真正的优势吗?
Which is recommended <h:commandButton>
or <h:commandLink>
? Is there any real advantage?
推荐答案
除了生成的标记和外观之外,没有功能上的区别. <h:commandButton>
生成HTML <input type="submit">
元素,而<h:commandLink>
生成使用JavaScript提交表单的HTML <a>
元素.两者都将用于提交表格.其他样式与功能无关.
There is no functional difference apart from the generated markup and the appearance. The <h:commandButton>
generates a HTML <input type="submit">
element and the <h:commandLink>
generates a HTML <a>
element which uses JavaScript to submit the form. Both are to be used to submit a form. Additional styling is irrelevant to the functionality.
如果需要提交按钮,请使用<h:commandButton>
;如果需要提交链接,请使用<h:commandLink>
.如果那样对您没有意义,那么我不知道.如果您不能决定使用哪一种,则只需选择在UI角度最有意义的一种即可.询问网页设计师是否不确定.
Use the <h:commandButton>
if you need a submit button and use the <h:commandLink>
if you need a submit link. If that doesn't make sense to you, then I don't know. If you can't decide which one to use, just choose the one which makes the most sense in UI perspective. Ask the web designer if you're unsure.
<h:commandLink>
和<h:outputLink>
之间的区别更有趣.在此处可以得到详细解答:何时应改为使用h:outputLink的h:commandLink?
The difference between <h:commandLink>
and <h:outputLink>
is by the way more interesting. This is been answered in detail here: When should I use h:outputLink instead of h:commandLink?
这篇关于h:commandbutton与h:commandlink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!