Il seguente esempio di frammento di codice descrive come scrivere il codice per generare i valori in un oggetto blob e restituirli per inserire i valori nel documento Microsoft Word. Tenere presente che i valori vengono inseriti sotto forma di coppie nome-valore utilizzando org.jdom.Element.
L'attributo NAME nella coppia nome-valore è il nome della DocProperty inserita nel modello. L'attributo VALUE corrisponde ai dati specifici per il corrispondente che sostituiranno il campo nella comunicazione Microsoft Word creata.
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());
Per ulteriori informazioni su come scrivere codice server, consultare la documentazione Cúram Server Developer Guide.