Advanced Customization > Business Logic Customization > DTI Customization Framework > Customize the Windchill tab in Microsoft Office > Implementation Example > Server-Side Customization
  
Server-Side Customization
Define the Custom Action
The following file is provided out-of-the-box with Windchill. The file is empty and can be used for this sample customization:
<Windchill>/codebase/config/actions/custom-actions.xml
Add the following XML text as a child node for the listofactions document node.
<objecttype name="customization" class="wt.doc.WTDocument">
<action name="DTICustomizationDemo">
<command class="com.ptc.dti.customization.forms.
TICustomizationFormProcessor"
method="execute" windowType="popup"
url="/netmarkets/jsp/customization/partPicker.jsp"/>
</action>
</objecttype>
This defines the DTICustomizationDemo action, which will be called from the DTI client side. On invocation of this action, a partPicker.jsp is launched. On completion of this action, a response is built in DTICustomizationFormProcessor.
Design the User Interface
For this example, you need the WTPart search and multiple part picker capability. This is implemented in partPicker.jsp using the itemPicker tag with WTPart as objectType.
<%@ taglib prefix="wctags" tagdir="/WEB-INF/tags" %>
<%@ include file="/netmarkets/jsp/components/beginWizard.jspf"%>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/dti" prefix="dti"%>
<wctags:externalFormData/>
<input type="hidden" name="fieldsToDisplay" id="fieldsToDisplay"
value="${dti:getCustomActionArg(param.externalFormData)}" />
<input type="hidden" name="selectedParts" id="selectedParts" value=" " />
<wctags:itemPicker id="dtiPartPicker"
inline="true"
pickerCallback="partPickerCallback"
componentId="dtiPartPicker"
pickerTitle="DTI Customization Part Picker Example"
objectType="wt.part.WTPart"
multiSelect="true"
/>

<SCRIPT>
function partPickerCallback(objects) {
var selectedPartsOid = '';
var myJSONObjects=objects.pickedObject;
for(var i=0; i< myJSONObjects.length;i++) {
if(i != 0){
selectedPartsOid += ';'; //partOID separator
}
selectedPartsOid += myJSONObjects[i]["oid"];
}
$("selectedParts").value = selectedPartsOid;
window.pickerCallback = "doNothing";
}
</SCRIPT>

<%@ include file="/netmarkets/jsp/util/end.jspf"%>
* 
Use the wctags:externalFormData tag to pass DTI data in the form of hidden field.
Use dti:getCustomActionArg(param.externalFormData) to capture the input argument that is send from DTI. It is passed to the form processor as a hidden field.
In this example, the argument sent is a list of Windchill part properties to query with ‘::’ as the separator(Name::Number::Version::State).
A pickerCallback function is defined, which will capture OIDs of selected parts and put it in a string with ‘;’ separators, then pass that list of selected parts OIDs to form processor through selectedParts hidden field. The following example displays the partPicker.jsp after searching and selecting a few records:
Implement the Form Processor
The form processor is implemented in the DTICustomizationFormProcessor.java file. The required data, such as fieldsToDisplay and selectedParts is obtained from beans data.
You can format the response in any format (such as XML, TXT, CSV) and put that in the session object in the form of a string. The same response is made available to the DTI client side as a response. The only requirement here is to pass DTI_CUSTOM_KEY=<dtiCustKey> as a part of wizardResponsehandler.
Below is sample code of the setResultNextAction method:
String responseString =
“<RESULTS>
<Result0 Name="01-51231.prt" Number="WCDS0000000104"
tate="INWORK" Version="A.1"/>
<Result1 Name="01-51246_2.prt" Number="WCDS0000000150"
tate="INWORK" Version="A.5"/>
<Result2 Name="01-52100.asm" Number="WCDS0000000473"
tate="INWORK" Version="A.2"/>
<Result3 Name="01-512040.asm" Number="WCDS0000000654"
tate="INWORK" Version="A.1"/>
<Result4 Name="01-51251a.prt" Number="WCDS0000000055"
tate="INWORK" Version="A.1"/>
<Result5 Name="01-512106a.prt" Number="WCDS0000000363"
tate="INWORK" Version="A.1"/>
</RESULTS>”;

String dtiCustkey = "DTI_CUST_DATA" + System.currentTimeMillis();
clientData.getRequest().getSession().setAttribute(dtiCustkey, responseString);
wizardResponseHandler += "&DTI_CUSTOM_KEY="+ dtiCustkey;
Here responseString is built as an XML response based upon properties to query and parts selected.
This same response string in the same format will be available at DTI client side.
Refer to the DTICustomizationFormProcessor.java file available in your Windchill installation for more details on implementation.