2
votes

I am using the following as a datasource for an xpage repeat control:

var extDB = session.getDatabase("","Position.nsf");
var emailNVCollection:NotesViewEntryCollection = extDB.getView("PrincipalEmails").getAllEntries();
return emailNVCollection

I know the syntax is correct because of the answer to: Making a viewEntryCollection an objectDataSource

What I cannot figure out is how to display the values in a computed field. I have tried simple binding using expression language: rowHandle.fieldname. And several different javascript methods such as rowHandle.getColumnValue that I found via many searches. They all return various errors. With the javascript I think that the methods I have tried are not valid for NotesViewEntryCollections. The expression language method returns: Error getting property 'fieldname' from bean of type lotus.domino.local.ViewEntry.

Here is the actual source:

<xp:panel style="margin-left:10.0px;margin-top:10.0px">
        <xp:repeat id="repeat1" rows="30" var="rowHandle">
            <xp:this.value><![CDATA[#{javascript:var extDB = session.getDatabase("","Position.nsf");
var emailNVCollection:NotesViewEntryCollection = extDB.getView("PrincipalEmails").getAllEntries();
return emailNVCollection}]]></xp:this.value>
            <xp:text escape="true" id="computedField1"
                value="#{rowHandle.posd_email}">
            </xp:text>
</xp:repeat></xp:panel></:view>

I think this should be simple. As usual. ---Lisa&

2

2 Answers

2
votes

You have a NotesViewEntryCollection as repeat's value.

Every rowHandle is then an instance of class NotesViewEntry.

You can access document's items with getDocument().

rowHandle.getDocument().getItemValueString("yourItemName")

Your example would be

    <xp:text escape="true" id="computedField1"
        value="#{javascript: rowHandle.getDocument().getItemValueString('posd_email')>
    </xp:text>

You get a better performance though if you use view's column values like the first column in this example:

rowHandle.getColumnValues().firstElement().toString()
0
votes

You wouldn't want to do that. Besides going against the MVC paradigm you are calling for performance problems already.

Although still rubbing the MVC paradigm the wrong way, XPages gives you the ability to break free from the underlying database objects and work with their counterpart wrappers (in this case ViewEntry to DominoViewEntry).

You must first define your data source (usually declared at the beginning of the page):

<xp:this.data>
    <xp:dominoView var="principalEmails" databaseName="Position.nsf"
        viewName="PrincipalEmails" />
</xp:this.data>

Then you reference the data source in the repeat control:

<xp:repeat id="repeatPrincipalEmails" value="#{principalEmails}" var="principalEmail">
    <xp:text value="#{principalEmail.posd_email}" />
</xp:repeat>

As long as the the value you define after the dot corresponds to the column programmatic name - that name automatically matches the field name if no formula is involved - you can reference any column present in the view.

If you need to reference any other field that is not in the view the best thing you can do is to refrain from getting to the domino document object itself and rather add another column with the field you need