203 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
Latest 7 Posts
Top 10

The Social Business Toolkit – First Project
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious

In the first two posts in this series I talked about the Social Business Toolkit (SBT) in general and showed how to install all necessary items in order to use the SBT in XPages.

  1. The Social Business Toolkit (SBT)
  2. The Social Business Toolkit – Getting Started

Today we are going to build an XPage, pull data from IBM Connections and show this data in a Data Table control. So let’s go. First we have to define our endpoint. The endpoint in SBT terms is the definition of the data connection to IBM Connections. We are going to use Basic Authentication in this example. Open you faces-config.xml and add the following lines:


You can copy the “_BasicLogin.xsp” XPage from the XPagesSBT.nsf that comes with the Social Business Toolkit. The next step is to create a Bean that establishes a connection and reads some data. So create a bean named ServiceBean and copy the following code:

package de.hedersoft.controller.impl;
import com.ibm.sbt.services.client.connections.files.FileList;
import com.ibm.sbt.services.client.connections.files.FileService;
import com.ibm.sbt.services.client.connections.files.FileServiceException;

public class ServcieBean implements Serializable {  
	private static final long serialVersionUID = 1L;  

	public FileList getMyFiles() {    
		FileService service = new FileService();    
		try {      return service.getMyFiles();    
		} catch (FileServiceException e) 
		{      return null;    }  

What this code does is pretty straight-forward, isn’t it. It get’s a handle to the FileService object (line 9) that the SBT provides and calls a function to get all files I have stored in the Connections file application (line 11). Then it returns a FileList object to the caller. We will use this FileList object later in our DataTable in order to iterate through the files. But first we have to register our Bean in order to access it. So open you faces-config.xml again and add the following lines:


The last thing we need is a page that shows all files that the ServiceBean returns from IBM Connections. So create a new XPage and name it “xpShowFiles”. Here is the XML to copy and paste into the Source Tab of your new page:

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

	<xp:dataTable id="dataTable1" rows="30" var="entry"
		styleClass="table table-striped table-condensed full-table-width">
		<xp:column id="column1">
				<xp:label value="File Name" id="label1"
			<xp:image id="image1">
				<xp:this.url><![CDATA[#{javascript:var docType:String = entry.getLabel().substring(entry.getLabel().lastIndexOf(".")+1,entry.getLabel().length);
if (docType.equals("pdf")) {
	return "/icon_pdf.png";
} else if (docType.equals("xls") || docType.equals("xlsx")) {
	return "/icon_spreadsheet.png";
} else if (docType.equals("doc") || docType.equals("docx")) {
	return "/icon_text.png";
} else if (docType.equals("ppt") || docType.equals("pptx")) {
	return "/icon_presentation.png";
} else if (docType.equals("jpg") || docType.equals("jpeg") || docType.equals("gif") || docType.equals("png")) {
	return "/icon_image.png";
} else {
	return "";
			<xp:link escape="true" text="#{javascript:' ' + entry.getLabel()}"
				<xp:this.value><![CDATA[#{javascript:return "./xsp/.proxy/files/connections/connections/"+entry.getLabel()+
		<xp:column id="column2">
				<xp:label value="Author" id="label2" xp:key="header"></xp:label>
			<xp:text escape="true" id="computedField2"
		<xp:column id="column3">
				<xp:label value="Created" id="label3" xp:key="header"></xp:label>
			<xp:text escape="true" id="computedField3"
		<xp:column id="column4">
			<xp:text escape="true" id="computedField4"
					<xp:convertNumber type="number"
				<xp:label value="Size (KB)" id="label4"


That’s it! Now what exactly is happening here? Well, first of all we define the data source for our data table in line 7. This data source comes straight from our Bean and is our FileList object. We define a variable called “entry” in line 5 that allows us to access all methods the FileList object provides. We then use the entry variable to access the file values like getLabel() – Filename and getAuthor() – Person who submitted the file. Check the SBT API documentation to find out which methods each and every object provides. The documentation comes with the SBT. The data table does the rest and iterates through all files. Here is what it looks like with a little bit of css Ashampoo_Snap_2013.12.20_14h28m04s_008_

Feb 18, 2014
5 hits

Recent Blog Posts

Created and Maintained by Yancy Lent - About - Planet Lotus Blog - Advertising - Mobile Edition