wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

By Date: October 2014

Custom REST service in XPages using a service bean


Talking to your backend using JSON and REST is all the rage for contemporary development. Domino has supported, at least reading, this access for quite a while using ?ReadViewEntries[&OutputFormat=JSON]. Using Domino Access Services (DAS) this has been extended to read/write support for documents as well.
However, as a result, your front-end application now needs to deal with the Domino way to present data, especially the odd use of @ in JSON keys (which e.g. jquery isn't fond of). Contemporary approaches mandate that you minimize the data you send over the wire and send data in your business structure, not in your database format. Furthermore, when sending data back, you want to validate and act on the data.
In the Extension Library there is the REST control, that you can use instead of the DAS service. It allows you to define what you want to expose as XML or JSON. There are a number of predefined service, but my favorite is the customRestService. When you use the custom service, you can write JavaScript for all events happening: doGet, doPost, doPut and doDelete, but you also can use a service bean. A service bean is not a managed bean, so you don't need to specify anything in your faces-config.xml. However it is a little special. A sample XPage could look like this:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
	xmlns:xe="http://www.ibm.com/xsp/coreex">
	
	<h1>This is the landing page of the orgSearch Service</h1>
	<p>Please use "search.xsp/json" for the actual query</p>

	<xe:restService id="JSONSearch" pathInfo="json" state="false">
		<xe:this.service>
			<xe:customRestService contentType="application/json"
				serviceBean="com.notessensei.demo.CustomSearchHelper">
			</xe:customRestService>
		</xe:this.service>
	</xe:restService>
	</xe:restService>
</xp:view>
if your page name is demo.xsp then the access to the service based on the pathInfo property is demo.xsp/json.

Read more

Posted by on 22 October 2014 | Comments (6) | categories: XPages

Purpose


" Follow your dreams" sounds good at first sight. Usually it gets grounded by " I need to make a living". Now Timothy Huges nicely summed it up: It isn't about passion or dreams, but purpose. Purpose is the intersection of four entities: Passion, Mission, Profession and Vocation
Click on the image for a bigger version
Enjoy!

Posted by on 21 October 2014 | Comments (0) | categories: After hours