Runtime components : Service components : Smart channel services : Smart data collector : Client collector
  
Client collector
The UDTT Smart client-side data collectors provide API to help collect the data from client and send to server side in order to record data into database.
Following are the general steps for smart client collector:
1 Add following jars into the web project: bttsmartchannel.jar, bttweb2collector.jar, bttweb2.jar, bttcore.jar, dwr.jar into the java build path and Java EE module.
2 Install Web2.0 feature pack for WAS, and copy the JSON4J.jar into the EAR project, and add it as the web project library. The JSON4J.jar is located at ${app_server_root}\web2fep\optionalLibraries\JSON4J.
3 Download the dwr.jar and copy it into the EAR project, and add it as the web project library. DWR is available under the Apache Software License v2 (http://www.apache.org/licenses/LICENSE-2.0.html). Download the file dwr.jar from http://directwebremoting.org/dwr/downloads/index.html.
4 Configure the DWR. See:
http://directwebremoting.org/dwr/introduction/getting-started.html
for more information. Following is the example used in the sample:
5 Create dwr.xml file under the WEB-INF folder in the web project, and add the following code:
<dwr>
<allow>
<create creator="new" javascript="SmartDataHandler">
<param name="class"
value="com.ibm.btt.channel.smart.web2.client.SmartDataHandler"/>
</create>
<create creator="new" javascript="SmartJMSDataHandler">
<param name="class"
value="com.ibm.btt.channel.smart.web2.client.SmartJMSDataHandler"/>
</create>
</allow>
</dwr>
Add following code to the web.xml file:
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param> <param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>initApplicationScopeCreatorsAtStartup</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>maxWaitAfterWrite</param-name>
<param-value>100</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet><servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
See also
Smart visit client collector
Smart preference client collector
Smart behavior client collector
Smart data collector
Smart visit client collector
The UDTT Smart visit client collector provides API to help collect the data when user logon and logout. To add smart visit collector to my project to collect the data when user logon and logout, you can:
1 Refer to general steps in Client collector.
2 Copy the file clientCollector.jsp from the bttweb2collector/client/collector directory into the web directory of the web project. Add bttweb2.jar into the build path and Java EE Module Dependencies of the web project.
3 Integrate the file clientCollector.jsp into the login destination web page to invoke the collector. Following is the sample code:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.ibm.btt.channel.smart.SmartDataCollectUtil" %>
<%@ page import="com.ibm.btt.http.WebChannelContext" %>
<jsp:useBean id="utb" scope="page"
class="com.ibm.sbtt.cs.html.DSEJspContextServices">
<% utb.initialize(request); %>
</jsp:useBean><% String userId=(String)utb.getContext().getValueAt("userId"); %>
<head><jsp:include page="clientCollector.jsp" flush="true"/> <script type="text/javascript"> saveVisitData("<%=userId%>"); </script></head>
See also
Client collector
Smart preference client collector
The UDTT Smart preference client collector provides API to help collect the data when users save the interested business items. To add smart preference client collector to project to collect the data when users save the interested business items, you can:
1 Refer to general steps in Client collector.
2 Copy the file clientCollector.jsp from the bttweb2collector/client/collector directory into the web directory of the web project. Add bttweb2.jar into the build path and Java EE Module Dependencies of the web project. Update the following code according to the real project:
<%
String profileRootPath=request.getRealPath("/")+"//BTTXML//";
String daoConfigPath="jar:///profileDefinitions/Web2ProfileDAO.xml";
String daoId="BTTWeb2ProfileFileDAO";
%>
The profileRootPath is the root path of all the user profiles. In this sample, the profiles are located at the BTTXMLfolder.
The daoConfigPath is the path of the Web2ProfileDAO.xml. This file is packaged in the profileDefinitions folder of the bttweb2collector.jar. You can also copy it into your project, and then configure the real path in the daoConfigPath.
The daoIdis the id of the profileDAO pattern of the UDTT web2.0 framework. There are two patterns: BTTWeb2ProfileFileDAOand BTTWeb2ProfileDB2DAO.
3 Integrate the clientCollector.jsp file into the web page in which the preference data is collected. Following is the sample code:
<script type="text/javascript">
BTTDemoPage.savePage=function(){
savePreferenceData(); }
</script>
Invoke the method to save preference. Following is the sample code:
<a href="javascript:void(BTTDemoPage.savePage())" id="save_page"></a>
See also
Client collector
Smart behavior client collector
The UDTT Smart behavior client collector provides API to help collect the data when users view the transaction information. To add smart behavior client collector to project to collect the data when users view the transaction information, you can:
1 Refer to general steps in Client collector.
2 Copy the file clientCollector.jsp from the bttweb2collector/client/collector directory into the web directory of the web project. Add file bttweb2.jar into the build path and Java EE Module Dependencies of the web project.
3 Create a .js script to define following code for preference collector.
saveBehaviorData(0,servId);
4 Invoke the method to save behavior. Following is the sample code:
addServiceListeners : function() {
BTTUtil.Servicelist.addListener( 'onclick', function(servId){
if(!BTTUtil.Servicelist.isCategoryNode(servId)) {
if(-1 != BTTUtil.Workarea.getIndex(BTTUtil.Workarea.getActiveTab())) {
BTTUtil.Workarea.addService(servId);
saveBehaviorData (0,servId); } else {
alert(BTTLocale.getText('can_not_add_service'));
}
}
});

}
See also
Client collector