Common document actionbar

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
	<xp:div styleClass="lotusActionBar">
		<xp:button value="Save" id="button1"
			rendered="#{javascript:currentDocument.isEditable()}">
			<xp:eventHandler event="onclick" submit="true"
				refreshMode="complete">
				<xp:this.action>
					<xp:saveDocument var="document1"></xp:saveDocument>
				</xp:this.action>
			</xp:eventHandler>
		</xp:button>
		<xp:button id="button2" rendered="#{javascript:currentDocument.isEditable()}">			
			<xp:this.value><![CDATA[Save & Close]]></xp:this.value><xp:eventHandler event="onclick" submit="true"
				refreshMode="complete">
				<xp:this.action>
					<xp:actionGroup>
						<xp:saveDocument var="document1"></xp:saveDocument>
						<xp:executeScript>
							<xp:this.script><![CDATA[#{javascript:return "close"}]]></xp:this.script>
						</xp:executeScript>
					</xp:actionGroup>
				</xp:this.action>
			</xp:eventHandler>
		</xp:button>
		<xp:button value="Edit" id="button3">
			<xp:this.rendered><![CDATA[#{javascript:var ctx = com.ibm.domino.xsp.module.nsf.NotesContext.getCurrent()
return ctx.isDocEditable(currentDocument.getDocument()) && !currentDocument.isEditable()}]]></xp:this.rendered>
			<xp:eventHandler event="onclick" submit="true"
				refreshMode="complete">
				<xp:this.action>
					<xp:changeDocumentMode mode="edit"></xp:changeDocumentMode>
				</xp:this.action>
			</xp:eventHandler>
		</xp:button>
		<xp:button id="button4">
			<xp:this.value><![CDATA[#{javascript:currentDocument.isEditable() ? "Cancel" : "Close"}]]></xp:this.value>
			<xp:eventHandler event="onclick" submit="true"
				refreshMode="complete" immediate="true">
				<xp:this.action><![CDATA[#{javascript:return "close"}]]></xp:this.action>
			</xp:eventHandler>
		</xp:button>
	</xp:div>
</xp:view>





This custom control assumes a data source named document1 and the usage of one of the OneUI themes. It displays 4 buttons: Save, Save & Close, Edit and Cancel/Close. Please make sure your xpage, that uses this control, has a navigation rule "close" to return to another page, e.g. a view.

XPages
Oliver Busse
January 3, 2014 4:46 PM
Rating
33

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...