The following sample code snippet illustrates how to write the code to build the values into a blob object and return it in order to insert the values into the Microsoft Word document. Note that values are inserted in the form of name-value pairs using the org.jdom.Element.
The NAME attribute in the name-value pair is the name of the DocProperty inserted in the template. The VALUE attribute is the correspondent-specific data that will replace the field in the created Microsoft Word communication.
org.jdom.Element rootElement = new org.jdom.Element("ROOT"); org.jdom.Element fieldsElement = new org.jdom.Element ("FIELDS"); org.jdom.Element fieldElement = new org.jdom.Element ("FIELD"); fieldElement.setAttribute ("NAME", "personName"); fieldElement.setAttribute ("VALUE", "James Smith"); fieldsElement.addContent (fieldElement); org.jdom.Element fieldElement1 = new org.jdom.Element ("FIELD"); fieldElement1.setAttribute ("NAME", "AddressLine1"); fieldElement1.setAttribute ("VALUE", "1074, Park Terrace"); fieldsElement.addContent (fieldElement1); org.jdom.Element fieldElement2 = new org.jdom.Element ("FIELD"); fieldElement2.setAttribute ("NAME", "AddressLine2"); fieldElement2.setAttribute ("VALUE", "Fairfield, Midway"); fieldsElement.addContent(fieldElement2); org.jdom.Element fieldElement3 = new org.jdom.Element ("FIELD"); fieldElement3.setAttribute ("NAME", "AddressLine3"); fieldElement3.setAttribute ("VALUE", "UTAH"); fieldsElement.addContent (fieldElement3); org.jdom.Element fieldElement4 = new org.jdom.Element ("FIELD"); fieldElement4.setAttribute ("NAME", "userName"); fieldElement4.setAttribute ("VALUE", "Caseworker"); fieldsElement.addContent (fieldElement4); rootElement.addContent (fieldsElement); return new curam.util.type.Blob ( new org.jdom.output.XMLOutputter .outputString(rootElement).getBytes());
For more information on how to write server code, see the Cúram Server Developer Guide.