In JSF 2, what is the difference between h:button and h:commandButton ?
This is taken from the book - The Complete Reference by Ed Burns & Chris Schalk
h:commandButton vs h:button
What’s the difference between h:commandButton|h:commandLink and h:button|h:link ?
The latter two components were introduced in 2.0 to enable bookmarkable
JSF pages, when used in concert with the View Parameters feature.
There are 3 main differences between h:button|h:link and h:commandButton|h:commandLink.
First,
h:button|h:linkcauses the browser to issue an HTTP GET request, whileh:commandButton|h:commandLinkdoes a form POST. This means that any components in the page that have values entered by the user, such as text fields, checkboxes, etc., will not automatically be submitted to the server when usingh:button|h:link. To cause values to be submitted withh:button|h:link, extra action has to be taken, using the “View Parameters” feature.The second main difference between the two kinds of components is that
h:button|h:linkhas an outcome attribute to describe where to go next whileh:commandButton|h:commandLinkuses an action attribute for this purpose. This is because the former does not result in an ActionEvent in the event system, while the latter does.Finally, and most important to the complete understanding of this feature, the
h:button|h:linkcomponents cause the navigation system to be asked to derive the outcome during the rendering of the page, and the answer to this question is encoded in the markup of the page. In contrast, theh:commandButton|h:commandLinkcomponents cause the navigation system to be asked to derive the outcome on the POSTBACK from the page. This is a difference in timing. Rendering always happens before POSTBACK.