DefaultCommand (<b:defaultCommand />)since 0.8.5

The <b:defaultCommand> controls which button fires the click event when the enter key is pressed.

Basic usage

The default command lets you specify which command has to be fired, using the target attribute set to the command id.

Live preview

The default command button is 'Button1'.



Responsive designsince 1.4.2

Since BootsFaces 1.4.2, the <b:defaultCommand /> also works with <b:commandButtons>> bearing a col-* or span attribute. Kudos go to GitHub user geopossachs who kindly contributed this improvement.

Live preview

The default command button is 'Button2'.

Multiple default commands in the same page

The <b:defaultCommand> component activates the click listener on the closest form of the component.
This way, you can define multiple defaultCommands in different form scopes.

Note that each form can support only a single defaultCommand. You have to split your page into several forms in order to add multiple defaultCommands. Also note that defaultCommands only apply to the surrounding form. Defining a default command in a form doesn't add a defaultCommand to any other form on the page.

Live preview

First Form (focus on input text and press enter key)

The default command button is 'Button 3'




Second Form (focus on input text and press enter key)

The default command button is 'Button 4'



Search Expressions

Default commands allow you to use search expressions. In many cases this allows you to get rid of the ids.

Live preview

The default command button is 'Button3'.



Reference section

Attribute Default value Description
id (none) Unique identifier of the component in a namingContainer.
rendered false Boolean value to specify the rendering of the component, when set to false the component will not be rendered.
target (none) Id of the default command for container div.