In order to use the SDK within your applications, you need to download and install the SDK.
There are simple Java snippets that can be run from an Eclipse IDE. The complete Eclipse workspace with the samples and a local Tomcat server comes with the SDK which can easily be used in Eclipse IDEs.
3. To update the build path and deployment assembly properties of
social.helloworld-web, right-click
social.helloworld-web and select
properties.
A. Select
Java Build Path >
Add Jars and add all SDK .jar files from the
lib folder.
B. Select
Deployment Assembly >
Add >
Java Build Path Entries and select all SDK .jar files.
C. Click
Apply and
OK.
4. Click
File >
New >
Servlet to create a new servlet for toolkit services. Provide the following information:
- Use the existing servlet class: com.ibm.sbt.service.core.servlet.ServiceServlet
- Name: ServiceServlet
- Description: The service servlet handles requests from the toolkit to access external resources.
- URL mappings: /service/*
5. Click
File >
New >
Servlet to create a new servlet for initializing the toolkit JavaScript library.
- Use the existing servlet class: com.ibm.sbt.jslibrary.servlet.LibraryServlet
- Name: LibraryServlet
- Description: This servlet initializes the specified JavaScript library for use by the Connections Cloud SDK.
- URL Patterns: /library/*
6. Click
File >
New >
Filter to create a new filter for creating the toolkit application and context objects. Provide the following information:
- Use the existing filter class: com.ibm.sbt.util.SBTFilter
- Description: This filter is responsible for creating the toolkit application and context objects for every servlet within this web application.
- URL Patterns: /*
7. Add the following lines to
web.xml.
<resource-ref>
<description>Reference to a URL resource which points to the configuration properties for the Social Business Toolkit.</description>
<res-ref-name>url/ibmsbt-sbtproperties</res-ref-name>
<res-type>java.net.URL</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
8. Create the file
managed-beans.xml in the
WebContent\WEB-INF folder.
9. Copy
sbt.properties from
sbtsdk\config and place it in
tomcat-config. This file needs to be customized, for example, with the URL to IBM Connections.
10. Create a new .jsp file named
ViewMyConnectionsFiles.jsp.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.ibm.sbt.services.client.connections.files.model.FileRequestParams"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.ibm.sbt.services.client.connections.files.FileService"%>
<%@page import="com.ibm.sbt.services.client.connections.files.model.FileEntry"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@page import="com.ibm.commons.runtime.Application"%>
<%@page import="com.ibm.commons.runtime.Context"%>
<html>
<head><title>My Files</title></head>
<body>
<div id="content">
<%
try {
FileService fileService = new FileService();
List<FileEntry> files = fileService.getPublicFiles(null);
if(files != null && ! files.isEmpty()) {
for (Iterator iterator = files.iterator(); iterator.hasNext();) {
FileEntry file = (FileEntry)iterator.next();
out.println("<a href=\"" + file.getDownloadLink() + "\"> " + file.getLabel() + "</a><br/>" );
}
} else {
out.println("No Results");
}
} catch (Throwable e) {}
%>
</div>
</body>
</html>
11. Right-click the .jsp file and select
Run as >
Run on Server for the configured server.
Click
Finish.