JSF <h:commandButton> Tag

It creates a submit button and used to submit a application form. You can create it by using the following syntax.


JSF <h:commandButton> Tag Example:

<h:form id="user-form">  
<h:outputLabel for="username">User Name</h:outputLabel>  
<h:inputText id="username" value="#{user.name}" required="true" requiredMessage="Username is required"/><br/>  
<h:commandButton id="submit-button" value="Submit" action="response.xhtml"/>  

JSF <h:commandButton> Tag Attributes:

Attribute Description
id It is an identifier for this component. This id must be unique. You can use it to access HTML element in CSS and JS file.
value It holds current value for the commandbutton and display it as name of submit button.
action It is used to specify action for the form. The commandButton submits the form to the server at the specified action. If you don't provide action, page redirect to the same page after submitting.
disabled It is used to make a commandButton disabled. You can't click on the button after applying this attribute.
image It is used to set an image on the commandButton. In this case, your image will work as submit button.
label It is used to make localized name for your comandButton.
rendered It is used to render the component. The default value for this property is true.
type It is used to specify type of button. You can set "reset", "submit" or "button". If don't specify, it is submit by default.
style It is used to specify CSS for the component.
onclick It is used to execute JavaScript code when commandButton is clicked.
accesskey It is used to access submit-button by using specified key.

© copyright 2017-2022 Completedone pvt ltd.