Establishing a session transaction for JSF channel

About this task

After the toolkit application is initialized, you need to establish session by using the UserBean class.

Procedure

  1. Define the JSF channel establish session backing bean in faces-config.xml:
    <managed-bean>
      <managed-bean-name>userBean</managed-bean-name>
      <managed-bean-class>com.ibm.btt.jsf.bean.UserBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
        <property-name>beanContextName</property-name>
          <value>sessionCtx</value>
      </managed-property>
    </managed-bean>
    Note: If you have already defined the branchServer context and sessionCtx context and their relevant data element in other channels, you can skip the second and the third step.
  2. Define the JSF establish session context in dsectxt.xml:
    <context id="branchServer" type="branch" parent="nil">
      <refKColl refId="branchData" />
    	 </context>
    
    <context id="sessionCtx" parent="branchServer" type="session">
      <refKColl refId="sessionData" />
    </context>
  3. Define the JSF establish session 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="dse_locale" />
      <refData refId="dse_errorMessages" />
      <refData refId="accounts" />
      <refData refId="forwardName" />
      <field id="currentStyle" />
      <field id="currentLocale" />
      <field id="currentDate" />
    </kColl>
  4. Implement JSF establish session bean in <toolkit_root>/samples/BTTMultiChannleSample/BTTSampleWeb/com.ibm.btt.jsf.bean.UserBean.java:
    Context sessionCtx = BTTJSFUtil.getSessionContext();
    if(sessionCtx == null) {
        sessionCtx = createSessionContext(getBeanContextName());
    }
    setBeanContext(sessionCtx);