Skip to main content link. Accesskey S
  • Overview ▾ Show Menu▼
  • APIs ▾ Show Menu▼
  • THIS WIKI IS READ-ONLY. Learn more...
  • IBM
  • Connections Developers
  • Home
  • Dev Guide
  • API Docs
  • SDK
  • Community
Dev Guide API Docs SDK Community This category IBM Social Business API Reference IBM Social Business Toolkit documentation Custom Search Scope...
Search
SDK > SDK docs > Web applications
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

Click to view profileIBM contributorIBM
Contribution Summary:
  • Articles authored: 853
  • Articles edited: 788
  • Comments Posted: 0

Recent articles by this author

Removing multiple members

To delete multiple members from an activity with one API request, send an Atom feed as part of a delete request to the activity ACL.

Adding multiple members

To add multiple members to an activity with one API request, send an Atom feed document containing entries of the new members to be added to the activity ACL.

Moving Nodes Under Different Activities or Nodes

To move an activity node to another activity node, use an HTTP POST request.

Moving fields between nodes

To move a field to another activity node, use an HTTP PUT request.

Working with following profiles using the Administration API

Working with following profiles using the Administration API
Web applications
Added by IBM contributorIBM | Edited by IBM contributorProjjwal Saha on July 18, 2013 | Version 18
  • Actions Show Menu▼
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars
expanded Abstract
collapsed Abstract
This topic describes how to create a web application on a Tomcat server using the Eclipse IDE and leveraging the Social Business Toolkit SDK JavaScript APIs.

This topic describes how to create a web application on a Tomcat server using the Eclipse IDE and leverage the Social Business Toolkit SDK JavaScript APIs.

Pre-requisites:
  • Social Business Toolkit SDK build. Download from the OpenNTF site.
  • Eclipse IDE configured with Tomcat server. There are articles explaining how to do this e.g. http://www.ibm.com/developerworks/library/os-eclipse-tomcat/

  1. Click New -> Dynamic Web Project to create a dynamic web project.
  2. Copy the jar files from sbtsdk\samples\war\sbt.sample.web\WEB-INF\lib to the WEB-INF\lib directory of the web project.
  3. Put a valid version of managed-beans.xml in the WEB-INF directory of the web project. It should have a managed-bean named connections to bring social data from IBM® Connections. To begin with, you can look at a sample managed-beans.xml from sbtsdk\samples\war\sbt.sample.web\WEB-INF
  4. Configure JNDI lookup.
  5. Copy the sbt.properties file from config directory of the SDK build to the conf folder of the Tomcat server installation.

    Create a resource URL in your context.xml file to add the location of sbt.properties. The Tomcat context.xml file is in the conf folder. Add the following line to the Context element:

    <Resource name="url/ibmsbt-sbtproperties" auth="Container" type="java.net.URL" factory="com.ibm.commons.runtime.naming.UrlFactory" url="sbt.properties" />

5. In web.xml of the application in WEB-INF, add the following lines of code to configure the proxy servlet, toolkit servlet, servlet filter, and the reference to the sbt.properties file.
<servlet>
		<description>The service servlet handles requests from the toolkit to access external resources.</description>
		<display-name>Social Business Toolkit Service Servlet</display-name>
		<servlet-name>ServiceServlet</servlet-name>
		<servlet-class>com.ibm.sbt.service.core.servlet.ServiceServlet</servlet-class>
</servlet>
<servlet-mapping>
		<servlet-name>ServiceServlet</servlet-name>
		<url-pattern>/service/*</url-pattern>
</servlet-mapping>
	
<servlet>
		<description>This servlet initializes the specified JavaScript library for use by the Social Business Toolkit.</description>
		<display-name>Social Business Toolkit Library Servlet</display-name>
		<servlet-name>LibraryServlet</servlet-name>
		<servlet-class>com.ibm.sbt.jslibrary.servlet.LibraryServlet</servlet-class>
		<init-param>
			<param-name>toolkitExtUrl</param-name>
			<param-value>%local_server%/sbtx</param-value>
		</init-param>
</servlet>
<servlet-mapping>
		<servlet-name>LibraryServlet</servlet-name>
		<url-pattern>/library/*</url-pattern>
</servlet-mapping>
		
<filter>
		<description>This filter is responsible for creating the toolkit application and context objects for every servlet within this web application.</description>
		<display-name>Social Business Toolkit Filter</display-name>
		<filter-name>SBTFilter</filter-name>
		<filter-class>com.ibm.sbt.util.SBTFilter</filter-class>
</filter>
<filter-mapping>
		<filter-name>SBTFilter</filter-name>
		<url-pattern>/*</url-pattern>
</filter-mapping>
		  	
<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>

6. Deploy sbt.war, available at redist\war directory in the SDK build, in the Tomcat server by copying the file to the webapps folder in the server installation file system.
Test the deployment with the following URL which should return a valid js file.

http://localhost:8080/sbt/js/sdk/sbt/xpath.js

7. Deploy sbt.dojo180.war, available at redist\war directory in the SDK build, in the Tomcat server by copying the file to the webapps folder in the server installation file system.
Test the deployment with the following URL which should return a valid js file.

http://localhost:8080/sbt.dojo180/dojo/dojo.js

8. Create an HTML file and place it in the WebContent directory of the web project. Add the following lines of code to see the list of ten public communities from Community Service of IBM Connections.

<script type="text/javascript" src="/sbt.dojo180/dojo/dojo.js"></script>
<script type="text/javascript" src="/<contextRoot>/library?lib=dojo&ver=1.8"></script>
<script type="text/javascript">
	        require([ "sbt/dom", "sbt/connections/CommunityService" ], function(dom, CommunityService) {
	            var createRow = function(i) {
	            var table = dom.byId("communitiesTable");
	            var tr = document.createElement("tr");
	            table.appendChild(tr);
	            var td = document.createElement("td");
	            td.setAttribute("id", "title"+i);
	            tr.appendChild(td);
	            td = document.createElement("td");
	            td.setAttribute("id", "id"+i);
	            tr.appendChild(td);
	        };
	        var communityService = new CommunityService();
	        communityService.getMyCommunities().then(
	            function(communities) {
	                if (communities.length == 0) {
	                    text = "You are not an owner of any communities.";
	                } else {
	                    for(var i=0; i<communities.length; i++){
	                        var community = communities[i];
	                        createRow(i);
	                        dom.setText("title"+i, community.getTitle()); 
	                        dom.setText("id"+i, community.getCommunityUuid()); 
	                    }
	                }
	            },
	            function(error) {
	                dom.setText("content", "Error code:" +  error.code + ", message:" + error.message);
	            }       
	         );
	       });
	</script>
	<table class="table table-bordered" id="communitiesTable">
	<tr class="label label-info">
		<th>Title</th>
		<th>Id</th>
	</tr>
               </table>

Replace the <ContextRoot> with the context root of the web application, created in the first step. Generally the context root is the same as the name of the application project.

Export this dynamic web project as a war file and put in the webapp directory of Tomcat server deployment.
Access the html page of the application to see the SDK in action.

Parent topic: Creating and deploying applications

  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (1)
collapsed Versions (1)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (18)Jul 18, 2013, 2:23:41 AMProjjwal Saha  IBM contributor
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMCnxDev on Twitter
  • ForumsIBMCnxDev on Stack Overflow
  • FacebookIBMSocialBizUX on Facebook
  • ForumsIBM Collaboration Solutions product forums
  • Community LinkThe Social Lounge
  • Wiki Help
  • Forgot user name/password
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use