Establishing a session transaction for Rich Client

Procedure

  1. Define the Rich Client parameter in btt.xml:
    <kColl id="java">
        <!-- Next requestHandler is an extension of the standard requestHandler to be used -->
        <!-- with the sample application only -->
        <field id="requestHandler"
            value="com.ibm.btt.cs.java.JavaRequestHandler" />
        <!-- Next requestHandler is the standard in the toolkit -->
        <field id="presentationHandler"
            value="com.ibm.btt.cs.java.JavaPresentationHandler" />
        <field id="cookies" value="true" />
        <field id="runInSession" value="true" />
    </kColl>
  2. Define the Rich Client startup operation in startUpServerOp.xml:
    <signInOp.xml>
        <operation id="startUpServerOp" context="startupServerCtx" 
            implClass="com.ibm.btt.sample.operation.StartUpServerOperation">
            <refFormat name="csReplyFormat" refId="startupRecFmt" />
        </operation>
    </signInOp.xml>
  3. Define the Rich Client startup related context in dsectxt.xml.
    Note: If you have already defined the branchServer context and sessionCtx context and their relevant data element in other channels, you only need to add the startupServerCtx context in dsectxt.xml and its relevant data element.
    <context id="branchServer" type="branch" parent="nil">
        <refKColl refId="branchData" />
        </context>
    
    <context id="sessionCtx" parent="branchServer" type="session">
        <refKColl refId="sessionData" />
    </context>
    
    <context id="startupServerCtx" type="op" parent="branchServer">
        <refKColl refId="startupServerData" />
    </context>
  4. Define the Rich Client startup data element in dsedata.xml:
    <!--relavant data element defination of branchServer context-->
    <kColl id="branchData" dynamic="true">
    		<refData refId="BranchId" />
    		<iColl id="languages" size="2">
    			<kColl id="language">
    				<field id="name" />
    				<field id="locale" />
    			</kColl>
    		</iColl>
    	</kColl>
    
    <!--relavant data element defination of sessionCtx context-->
    <kColl id="sessionData">
    		<refData refId="TID" />
    		<refData refId="userId" />
    		<refData refId="CustomerId" />
    		<refData refId="CustomerName" />
    		<refData refId="HostBuff" />
    		<refData refId="sessionID" />
    		<refData refId="dse_locale" />
    		<refData refId="dse_errorMessages" />
    		<refData refId="accounts" />
    		<refData refId="forwardName" />
    
    		<refData id="telephone" />
    		<refData id="address" />
    		<refData id="email" />
    
    		<field id="currentStyle" />
    		<field id="currentLocale" />
    		<field id="currentDate" />
    	</kColl>
    
    <!--relavant data element defination of startupServerCtx context-->
    <kColl id="startupServerData">
        <refData refId="TID" />
        <refData refId="sessionID" />
        <refData refId="TrxReplyCode" />
        <field id="eventsPort" />
        <field id="ipAddress" />
        <field id="permanentConnectionForEvents" />
        <field id="instanceId" />
    </kColl>

  5. Implement Rich Client startup operation in <toolkit_root>/samples/BTTMultiChannleSample/SampleBusiness/com.ibm.btt.sample.operation.StartUpServerOperation.java:
    public class StartUpServerOperation extends BTTServerOperation{
    
    public void execute() throws Exception {
    Context root = ContextFactory.getRoot();
    if (root == null) {
    System.out.println("Creating root ctx");
    root = ContextFactory.createContext("branchServer", false);
    }
    System.out.println("Create session context");
    Context sessionCtx = ContextFactory.createContext("sessionCtx", false);
    sessionCtx.chainTo(root);
    setValueAt("TrxReplyCode","OK");
    HttpSession session =WebChannelContext.getHttpServletRequest().getSession();
    
    final SessionEntry se = new SessionEntry(session);
    se.setSessionId(session.getId());
    se.setCurrentContext(sessionCtx);
    CSSessionHandler.addSession(se);
    System.out.println("Create session context success....");
    }
    
    }