Buttons for a form in a Custom Control

There are standard buttons that are often added to a form that perform the basic functions (edit, save, close) that usually you put in a form.
The code in this post is a Custom Control that you can add to a XPage connected to a lotus form to place the buttons Edit, Save and Close.
In the XPage under the label “Data” configure “Data sources” to the form lotus and under the label “XPage” set the “Next Page” as follows:



Create and add a Custom Control to the XPage with the following code:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

	<xp:button value="Edit" id="btnEdit"
		rendered="#{javascript:!currentDocument.isEditable()}">
		<xp:eventHandler event="onclick" submit="true"
			refreshMode="complete">
			<xp:this.action>
				<xp:changeDocumentMode mode="edit" />
			</xp:this.action>
		</xp:eventHandler>
	</xp:button>
	
	<xp:button value="Save" id="btnSave"
		rendered="#{javascript:currentDocument.isEditable()}">
		<xp:eventHandler event="onclick" submit="true"
			refreshMode="complete" immediate="false" save="true">
			<xp:this.action>
				<xp:actionGroup>
					<xp:saveDocument />
				</xp:actionGroup>
			</xp:this.action>
		</xp:eventHandler>
	</xp:button>
	
	<xp:button id="btnClose" value="Close">
		<xp:eventHandler event="onclick" submit="true"
			refreshMode="complete" immediate="true" save="false"></xp:eventHandler>
	</xp:button>

</xp:view>

The code rendered=”#{javascript:!currentDocument.isEditable()}” hides the buttons Edit and Save if the document isn’t in edit mode.
The code refreshMode=”complete” refreshes the full page.
The code immediate=”true” if the page is refreshed or a new page is open, the page stops to process (for example the fields are not validated and the latest input entered by the user is lost), used in cancel buttons.
The code immediate=”false” even if the page is refreshed or a new page is open, the page lifecycle continues, used in submit buttons.

As you can see the buttons in the client designer:


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.