The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

8upPickles (2) [Avatar] Offline
#1
If this question seems somewhat elementary, it is because I am new to both Domino and Java. I am trying to develop WQO agent in Java to create a delimited list of field names from a form. My code is giving me the last field name without adding any other field names. Does anyone have an suggestions or advice. My code is posted below. Thank you for your help.

8upPickles

CODE:

import lotus.domino.*;
import java.util.*;
import java.lang.*;

public class DocumentProperties extends AgentBase {
public void NotesMain() {
try {
Session s = getSession();
AgentContext ac = s.getAgentContext();
Database db = ac.getCurrentDatabase();
Document doc = ac.getDocumentContext();
String conflictID = doc.getItemValueString("RepSaveUNID");
String parentID = doc.getItemValueString("ParentDocRef");
Vector pAuthor;
Vector cAuthor;
String string = null;

if (doc != null) {

Document pdoc = db.getDocumentByUNID(parentID);
Document cdoc = db.getDocumentByUNID(conflictID);

Enumeration parent2 = pdoc.getItems().elements();
while ( parent2.hasMoreElements() ) {
Item items = (Item) parent2.nextElement();
//string = items.getName();
//string = string.concat(string);
//doc.replaceItemValue("FieldList", string);
}

Vector parent = pdoc.getItems();
Vector conflict = cdoc.getItems();
pAuthor = pdoc.getAuthors();
cAuthor = cdoc.getAuthors();

//trying to build a string list of field names delimited by a semicolon
for ( int j = 0; j<parent.size(); j++ ) { >
Item parent1 = (Item)parent.elementAt( j );
doc.replaceItemValue("Winner", Integer.toString(j) + " " + parent1.getName() + "= " + parent1.getText());
string = parent1.getName();
string += ";" + string;
doc.replaceItemValue("FieldList", string);
}

for ( int i = 0; i<conflict.size(); i++ ) { >
Item conflict1 = (Item)conflict.elementAt( i );
doc.replaceItemValue("Loser", Integer.toString(i) + " " + conflict1.getName() + "= " + conflict1.getText());
}

//Code for comparing document properties
doc.replaceItemValue("ParentDocument", "Created: " + pdoc.getCreated() + "
"
+ "Notes ID: " + pdoc.getNoteID() + "
"
+ "Document is signed: " + pdoc.isSigned() + "
"
+ "Size (in bytes): " + pdoc.getSize() + "
"
+ "UNID: " + pdoc.getUniversalID() + "
"
+ "Last Modified: " + pdoc.getLastModified() + "
"
+ "Last Modified By: " + pAuthor.lastElement());

doc.replaceItemValue("ConflictDocument", "Created: " + cdoc.getCreated() + "
"
+ "Notes ID: " + cdoc.getNoteID() + "
"
+ "Document is signed: " + cdoc.isSigned() + "
"
+ "Size (in bytes): " + cdoc.getSize() + "
"
+ "UNID: " + cdoc.getUniversalID() + "
"
+ "Last Modified: " + cdoc.getLastModified() + "
"
+ "Last Modified By: " + cAuthor.lastElement());



cdoc.recycle();
pdoc.recycle();
}

doc.recycle();
s.recycle();
ac.recycle();

} catch(Exception e) {
e.printStackTrace();}
}
8upPickles (2) [Avatar] Offline
#2
Re: building a list of fields from a form
Figured out the answer to my question. Changed this code:

string = parent1.getName();

to

string += parent.getName() + ";";

and removed the other concatination.