Tobago Demo

Menu

Default Command

A normal button, created with <tc:button/>, must be actively pressed, to run the action. A default-button can be activated, even if not selected. For example, the cursor is in an input field and the enter key is pressed.

A button can be made to a default button with the defaultCommand attribute. The default button is highlighted by another color.

Tag Library Documentation

Last Active Button ID

To make the examples more clear, the ID of the last active button is displayed in the following output field.

Basics

After writing some text into the textfield, the user can press 'ENTER' to activate the submit-button.

Multiple Default Buttons

The related default-button is searched in the current <tc:form/>. If there no default-button could found, the search is continued in the parent form and so on. If no default-button found on this way, the button is search outside of a form.

In this example, the 'Submit A'-button is in a form together with a intputfield and output field. The 'Submit B'-button is outside a form.

Now, if the cursor is in 'Textfield A' and the enter key is pressed, the 'Submit A'-button is activated. Therefor only the 'Textfield A'-value will be submitted.

If the cursor is in 'Textfield B' and the enter key is pressed, the 'Submit B'-button is activated. This will submit the 'Textfield A'-value as well as the 'Textfield B'-value.

© 2005-2023 Apache Software Foundation, Licensed under the Apache License, Version 2.0.