ShowTable of Contents
NotesXspDocument
This Open simple action uses scripts to set a condition and to specify a target.
<xp:button id="button1" value="Open parent"><xp:eventHandler event="onclick" submit="true" refreshMode="complete"> <xp:this.action>
<xp:actionGroup
condition="#{javascript:document1.isResponse()}">
<xp:openPage name="/main.xsp"
target="#{javascript:return document1.getParentId()}">
</xp:openPage>
</xp:actionGroup>
</xp:this.action></xp:eventHandler></xp:button>
getAttachmentList
This onclick event gets the names of any attachments to the document. The variable requestScope.xml is bound to a multiline edit box.
var alist = document1.getAttachmentList("body");
if (alist.isEmpty()) {
requestScope.alist = "No attachments"
} else {
var result = alist.length.toString() + " attachments\n";
var alisti = alist.iterator();
// Each element is of type NotesEmbeddedObject
while (alisti.hasNext()) {
result = result + alisti.next().getName() + "\n";
}
requestScope.alist = result;
}
getDocument
This button onclick event gets the XML for the document (updated with any changes made in the data store) associated with the current XPage. Elsewhere on the XPage requestScope.xml is bound to a multiline edit box.
requestScope.xml = document1.getDocument(true).generateXML()
getForm
This code computes the form for a data source, specifying it as the same form used for document1.
return document1.getForm()
getItemValue
This data binding for a multiline edit box returns the values of the Numbers item in the document associated with the current XPage.
var v = document1.getItemValue("Numbers");
if (v.isEmpty()) {
return "Numbers is empty or doesn't exist";
} else {
var result = "";
var vi = v.iterator();
while (vi.hasNext()) {
result = result + vi.next().toFixed() + "\n";
}
return result;
}
getItemValueArray
This data binding for a multiline edit box returns the values of the Numbers item in the document associated with the current XPage.
var array = document1.getItemValueArray("Numbers");
if (array.length == 0) {
return "Numbers is empty or doesn't exist";
} else {
var result = "";
for (var i=0; i<array.length; i++) {
result = result + array[i].toFixed() + "\n";
}
return result;
}
getItemValueDate
This computed field that returns the value of the datetime item in the document associated with the current XPage.
var d = document1.getItemValueDate("datetime");
if(d == null) {
return "datetime is empty or doesn't exist."
} else {
return d.toLocaleString();
}
getItemValueDateTime
This data binding for a computed field returns the value of the datetime item in the document associated with the current XPage.
var d = document1.getItemValueDateTime("datetime");
if(d == null) {
return "datetime is empty or doesn't exist."
} else {
return d.getLocalTime()
}
getItemValueDouble
This value for a computed field returns the value of the Number item in the document associated with the current XPage.
var n = document1.getItemValueDouble("Number");
if(n == 0.0) {
return "Number is empty or doesn't exist."
} else {
return n;
}
getItemValueInteger
This value for a computed field returns the value of the Number item in the document associated with the current XPage.
var n = document1.getItemValueInteger("Number");
if(n == 0) {
return "Number is empty or doesn't exist."
} else {
return n.toFixed();
}
getItemValueString
This data binding for a computed field returns the value of the Subject item in the document associated with the current XPage.
var s = document1.getItemValueString("Subject");
if(s == "") {
return "Subject is empty or doesn't exist."
} else {
return s;
}
getNoteID
This button assigns the note ID of the document associated with the current context to a session variable.
sessionScope.noteid = document1.getNoteID()
A button on another page uses the session variable to determine the target document for an Open simple action.
return sessionScope.noteid
The button for the Open simple action is visible only if the note ID is set.
sessionScope.noteid != null
getParentDatabase
This computed field displays the title of the parent database of the document associated with the current context.
return document1.getParentDatabase().getTitle()
getParentId
This code gets the target document for an Open simple action.
return document1.getParentId()
This is the condition for a group that precedes the above event.
getValue
This button onclick event totals the numbers in a multiline edit box.
var v:java.util.Vector = document1.getValue("numbers");
var vi = v.iterator();
var total = 0.0;
while (vi.hasNext()) {
total = total + vi.next() * 1.0; // need * 1.0 to force vi.next() to number
}
document1.setValue("numbers", total)
hasItem
This computed field returns the value of an item in the document associated with the current XPage if the item exists.
if(document1.hasItem("number")) {
return document1.getItemValueDouble("number").toString();
} else {
return "number does not exist"
}
isEditable
This button onclick event saves the document if it is in edit mode.
if (document1.isEditable()) {
document1.save();
requestScope.status = "Document saved";
} else {
requestScope.status = "Document not in edit mode";
}
isNewNote
This label displays a message if the document associated with the current XPage is new and an item value if it is not new.
if(document1.isNewNote()) {
return "New subject";
} else {
return document1.getItemValueString("subject");
}
isResponse
This code gets the target document for an Open simple action. The target document is its parent.
return document1.getParentId()
This is the condition for the group to which the above event belongs.
removeAllAttachments
This button onclick event removes all attachments from the body item if there are any.
if (document1.getAttachmentList("body").isEmpty()) {
requestScope.alist = "No attachments in body";
} else {
document1.removeAllAttachments("body");
requestScope.alist = "All attachments removed from body";
}
removeAttachment
This button onclick event removes an attachment from the body item if it exists.
if (document1.getAttachmentList("body").isEmpty()) {
requestScope.alist = "No attachments in body";
} else {
if (document1.removeAttachment("body", requestScope.rname)) {
document1.save();
requestScope.alist = "Attachment " + requestScope.rname + " removed from body";
} else {
requestScope.alist = "Attachment " + requestScope.rname + " does not exist";
}
}
removeItem
This button removes the number item from the current document if it exists.
if (document1.hasItem("number")) {
document1.removeItem("number");
document1.save();
requestScope.alist = "Removed number item";
} else {
requestScope.alist = "No number item in document";
}
replaceItemValue
This button increments the value of an edit box by 1 and saves the new value.
document1.replaceItemValue("counter", document1.getItemValueInteger("counter") + 1;
document1.save();
This button sets values for a multi-value edit box without saving them.
var n = new Array(22, 33, 44);
document1.replaceItemValue("number", n);
This button sets values for a multi-value edit box without saving them.
var n = new java.util.Vector();
n.addElement(22);
n.addElement(33);
n.addElement(44);
document1.replaceItemValue("number", n);
save
This button sets a value for the subject item if it has none, saves the document, and opens the previous page.
if (document1.getItemValueString("subject").trim().length == 0 {
document1.setValue("subject", "No subject");
}
document1.save();
context.redirectToPrevious();
setValue
This button increments the value of an edit box by 1 and saves the new value.
document1.setValue("counter", document1.getItemValueInteger("counter") + 1;
document1.save();
This button sets values for a multi-value edit box without saving them.
var n = new Array(22, 33, 44);
document1.setValue("number", n);
This button sets values for a multi-value edit box without saving them.
var n = new java.util.Vector();
n.addElement(22);
n.addElement(33);
n.addElement(44);
document1.setValue("number", n);