Home » Primefaces CommandButton

Primefaces CommandButton

by Online Tutorials Library

PrimeFaces CommandButton

It is an extended version of standard h:commandButton of JSF. It includes ajax, partial processing and skinning features.

The <p:commandButton> component is used to create button in JSF application. It is useful when we want to perform action in web application.

This component has various attributes that are tabled below.

CommandButton Attributes

Attribute Default value Type Description
rendered true Boolean It is used to specify the rendering of the component.
value null String It is used to set label for the button.
action null MethodExpr/String It is used to set action when button is clicked.
actionListener null MethodExpr It is used to set actionlistener that’d be processed when button is clicked.
type submit String It sets the behavior of the button.
ajax true Boolean It specifies the submit mode.
async false Boolean When set to true, ajax requests are not queued.
process null String It is used to process partially instead of whole view.
update null String It is used for component to be updated with ajax.
global true Boolean It defines whether to trigger ajaxStatus or not.
delay null String It is used to set delay value.
partialSubmit false Boolean It enables serialization of values belonging to the partially processed components only.
timeout 0 Integer It is used to set timeout for the ajax request in milliseconds.

Example

Here, in the following example, we are implementing <p:commandButton> component. This example contains the following files.

JSF File

// commandButton.xhtml

ManagedBean

// CommandButton.java

Output:

PrimeFaces CommandButton 1
PrimeFaces CommandButton 2

You may also like