SNTT: Examples of accessing data on Xpages

There are several ways of getting at the data on an Xpage. I wanted to understand this better so I have created this example which gives examples of

getComponent( “element name”).getValue();
getComp onent(“element name”).getSubmittedValue()
currentDocument.getItemValueString(“back end field name / data source name”)

The key learning for me has been that the getSubmittedValue method will only work if the “Do not validate or update data” property is set. If it is not set then the value returned is null even though the name would suggest that it returns the “submitted value”.

Image:SNTT: Examples of accessing data on Xpages

This means that in the case of a document which is not new you may need to test for both the existing value and the submitted value if you are using a two stage drop down as described by Tim Clark. The code I have used in a recent project is :

// the submitted value is not available
// until on onchange event has occurred
var keyvar : String;
var combo4SV = getComponent(“comboBox4”).getSubmittedValue();
var combo4 = getComponent(“comboBox4”).getValue();
if(combo4SV === null){keyvar = combo4} else {keyvar = combo4SV};
@DbLookup(@DbName(), “vpeepsbyorgname”, keyvar, 2)

There is also a similar example listed under “Combining getValue and getSubmittedValue” in the Redbooks Wiki: Building Domino Web Applications using Domino 8

I have also found the following links useful :

You at Notes Wiki
Embedding Contextual Data for Client-Side Logic in XPages
Paul Hannan


Leave a Reply

Your email address will not be published. Required fields are marked *

2 + 4 =