button - Button

Displays a button that the user can click to perform an action.

Category

Core Controls

Syntax

<xp:button attributes>content</xp:button>
Table 1. Essential properties
Property Description
id Defaults to button1, button2, and so on.
value Specifies the label for the button.
eventHandler Specifies the action when the button is activated. See the usage section.

Usage

At run time, a button appears on the page. The user can click the button.
Buttons are of three types:
  • Button (default) responds to event handlers that you create, for example, for onclick. For accessibility compliance, the value property must describe the action being performed.
  • Submit saves data and closes the page. For accessibility compliance, the value property must be Submit.
  • Cancel closes the page. For accessibility compliance, the value property must be Cancel.
When a page is closed, the next page loaded is determined by the navigationRules property for the page which is Next page (success or cancel) in the UI.
To set the button type in the UI, click Button under Properties and look for Button type. The generated eventHandler property has the following attributes. Follow these rules if you construct the eventHandler property manually.
Button Submit Cancel
event=any event="onclick" event="onclick"
submit=any submit="true" submit="true"
refreshMode=any refreshMode="complete" refreshMode="complete"
immediate=any immediate="false" immediate="true"
save=any save="true" save="false"
action=simple action or event handler action=none action=none

Examples

This Button control is of type Submit.
<xp:button id="button1" value="Submit">
	<xp:eventHandler event="onclick"
		submit="true" refreshMode="complete" immediate="false" save="true">
	</xp:eventHandler>
</xp:button>
This Button control is of type Cancel.
<xp:button id="button2" value="Cancel">
	<xp:eventHandler event="onclick"
		submit="true" refreshMode="complete" immediate="true" save="false">
	</xp:eventHandler>
</xp:button>
This Button control is of type Button and executes the Save Data simple action when clicked.
<xp:button id="button1" value="Save and Exit">
	<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
		<xp:this.action>
			<xp:save name="/xpage2.xsp"></xp:save>
		</xp:this.action>
	</xp:eventHandler>
</xp:button>