Free Support Forum -

Control Data Insertion into Merge Fields during Mail Merge using Java Classes Implementing IFieldMergingCallback


I’m working with the doc.getMailMerge().setFieldMergingCallback method and comparing it to how I’ve used it in the .NET in the past.

I’d like to have multiple classes to handle some special behavior, but it appears that I can only reference one class for the callback class, is that right? In other words, it appears this isn’t possible:

document.getMailMerge().setFieldMergingCallback(new MergeFieldCallback_A());
document.getMailMerge().setFieldMergingCallback(new MergeFieldCallback_B());
document.getMailMerge().setFieldMergingCallback(new MergeFieldCallback_C());
document.getMailMerge().setFieldMergingCallback(new MergeFieldCallback_D());

where each is a separate class. Am I missing something?

I suppose I can create one class and consolidate all of the behavior. I just liked the old MergeFieldHandler behavior.

~~ Michael

Hi Michael,

Thanks for your inquiry.

You’re correct that the callback only allows once registered instance. We shifted to using callbacks and this design constraints when our .NET code was made autoportable to Java. I know this is a little different from events in .NET where you can register many instances.

The best way forward would be as you say to create your own intermediary class to handle multiple instances.