Advanced Customization > Services and Infrastructure Customization > Import Export Framework > How to Write Exp/Imp Handlers > DTD Files > How to Write an Attribute Export Handler
  
How to Write an Attribute Export Handler
If there is an attribute that is required to be exported the same way for different classes or if you simply decide to handle it is a separate handler, you can create an attribute handler. The steps to follow are:
1. Create a Java class extending AttrExporterImporterTemplate.
2. Implement exportAttribute(Object ob,IxbElement fileXML, Exporter exporter) method, which retrieves the attribute data from the object and adds it to the XML DOM Document. The following is an example of this method for the object “MyObject”. This method gets the part type and the part source of the object.
public void exportAttribute (
Object obj,
IxbElement fileXML,
Exporter exporter) throws WTException {
try {
MyClass ob = (MyClass) obj;
LocalizableMessage localMessage1 = ob.getDisplayType();
Locale locale1 = new Locale("English", "US");
String dispType = localMessage1.getLocalizedMessage(locale1);
fileXML.addValue(IxbHndHelper.XML_ATTR_PARTTYPE, dispType);
fileXML.addValue(
IxbHndHelper.XML_ATTR_SOURCE,ob.getSource ().toString() );
}
catch (Exception e) {
LogHelper.devExc (e,
"Exception in ExpImpForLTPartAttr, ob=<"+obj+">");
}
}
3. After adding this, the export handler for class may call this method to have the part attribute exported.