Simple actions

A simple action performs a pre-programmed activity that can be modified by arguments. Simple actions apply to event handlers. Simple actions can be grouped.

Simple actions enumerated

Simple actions are categorized as Basic, Component, and Document.
The following simple actions apply to server event handlers:
The following simple actions apply to client event handlers:

See Simple actions for the complete reference.

Simple actions by example

The following Source XML examples apply to the onclick event for a button. For Design mode instructions, see Working with simple actions.
  • One server-side action
    This event handler executes the server-side Open Page simple action. In the Design mode dialog, you select Open Page as the action, xpage1 as the first argument, and New document as the second argument.
    <xp:button id="button1" value="Go back">
    	<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
    		<xp:this.action>
    			<xp:openPage name="/xpage1.xsp" target="newDocument"></xp:openPage>
    		</xp:this.action>
    	</xp:eventHandler>
    </xp:button>
  • One client-side and one server-side simple action
    This event handler contains both client and server simple actions. The handler first executes the client-side Execute Client Script action. If the client script returns true, the handler executes the server-side Open Page simple action.
    <xp:button id="button1" value="Go to page 1">
    	<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
    		<xp:this.action>
    			<xp:openPage name="/xpage1.xsp" target="newDocument"></xp:openPage>
    		</xp:this.action>
    		<xp:this.script>
    			<xp:executeClientScript>
    				<xp:this.script>
    					<![CDATA[return window.confirm("Do you really want to go to page 1?")]]>
    				</xp:this.script>
    			</xp:executeClientScript>
    		</xp:this.script>
    	</xp:eventHandler>
    </xp:button>

Simple action groups by example

Simple actions can be placed in groups to multiple depths. Groups allow multiple client and server actions for an event, and provide for conditional execution. Actions exist for executing scripts so you can group scripts.
  • One server-side action in a group with a condition
    This event handler executes the server-side Open Page simple action conditionally by placing it in a group.
    <xp:button id="button1" value="Go to page 1">
    	<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
    		<xp:this.action>
    			<xp:actionGroup>
    				<xp:this.condition>
    					<![CDATA[#{javascript:return session.getCommonUserName() != "Anonymous"}]]>
    				</xp:this.condition>
    			<xp:openPage name="/xpage1.xsp" target="newDocument"></xp:openPage>
    		</xp:actionGroup>
    	</xp:this.action>
    </xp:eventHandler>
    </xp:button>
  • Three server-side actions in a group
    This event handler executes the server-side Confirm Action, Save Document, and Open Page simple actions sequentially by placing them in a group. A return value of false for the first action stops execution of the remaining actions.
    <xp:button id="button1" value="Go to page 1">
    	<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
    		<xp:this.action>
    			<xp:actionGroup>
    				<xp:confirm message="Do you really want to go to page 1?"></xp:confirm>
    				<xp:saveDocument></xp:saveDocument>
    				<xp:openPage name="/xpage1.xsp" target="newDocument"></xp:openPage>
    			</xp:actionGroup>
    		</xp:this.action>
    	</xp:eventHandler>
    </xp:button>