Extending a transaction context

The transaction context passing feature provides you with the ability to add your own attributes to a transaction context.

The following sample XML snippet shows the DWLControl object with an extension:
<DWLControl>
            <requesterName>Security Only User</requesterName>
            <requesterLanguage>100</requesterLanguage>
            <userRole>UserAll1</userRole>            				
            <ControlExtensionProperty name= "associatedContexts">testTransactionContext</ControlExtensionProperty>
            <ControlExtensionProperty name="currentContext">test</ControlExtensionProperty>	
</DWLControl>
Two new context attributes have been added to DWLControl in the sample:
name="associatedContexts" and value="testTransactionContext"
name="currentContext" and value="test"
You can extend the transaction context by using the recommended template:
<ControlExtensionProperty name="NewContextName">NewContextValue
</ControlExtensionProperty>
Fill in the NewContextName and NewContextValue with the preferred name and value pair in the template in the request XML. The request XML can provide multiple extension properties.

The transaction context is wrapped in the ControlExtensionProperty class, which has three fields: name, value, and includedInResponse.

The default value for the field includedInResponse in the ControlExtensionProperty class is true, meaning that this context extension will be returned in the response XML file. If you want to hide the context extension in response XML file, you must set the includedInResponse flag to false in the client code. Refer to the preceding sample code for detail.

Sample code that retrieves the transaction context extension:
//context extension name
        String attName = null;
//context extension value
ControlExtensionProperty attValue = null;

Hashtable properties = new Hashtable();
DWLControl context =//get DWLControl instance from BObj/EObj or method signature;
Map extMap = (Map)context.getControlExtensionMap();
if(extMap != null && !extMap.isEmpty()){
	  Iterator it = extMap.keySet().iterator();		
		
	  //loop through all the elements
	  while (it.hasNext()) {
	    //retrieve context extension from map:
	    attName = (String)it.next();
			
	    if(attName != null && attName.length() >0) {
	      attValue = (ControlExtensionProperty)extMap.get(attName);
	    
   	      //put the key/value pair to hashtable for later use:
		properties.put(attName, attValue. getValueAsString());
	      
//if clients want to hide context extension in response,
//the includedInResponse flag must be set to false. 
//E.g. attValue.setIncludeInResponse(false);
            …
    }								 				 			
	}