Reputation: 1070
I am attempting to display a subset of a view in a repeat control by getting a NotesViewEntryCollection and then looping through this collection to build an array for which each value in the array contains an array corresponding to the column values in the entry.
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:repeat id="repeat1" rows="30" var="rowData" indexVar="rowIndex">
<xp:this.value><![CDATA[#{javascript:
var view:NotesView = database.getView("CatalogEntries");
var entryColl:NotesViewEntryCollection = view.getAllEntriesByKey(compositeData.catalog, true);
if (entryColl.getCount() == 0) return ["empty"];
var entries = [];
var columnVals = [];
var entry:NotesViewEntry = entryColl.getFirstEntry();
do {
columnVals = [];
columnVals.push(entry.getColumnValues()[0]);
columnVals.push(entry.getColumnValues()[1]);
columnVals.push(entry.getColumnValues()[2]);
columnVals.push(entry.getColumnValues()[3]);
columnVals.push(entry.getColumnValues()[4]);
columnVals.push(entry.getColumnValues()[5]);
entries.push(columnVals);
entry = entryColl.getNextEntry(entry);
} while(!(entry == null))
return entries;}]]></xp:this.value>
<xp:text escape="true" id="computedField1" value="#{javascript:rowData[rowIndex][0]}"></xp:text>
</xp:repeat>
</xp:view>
But I am getting an error at this line:
<xp:text escape="true" id="computedField1" value="#{javascript:rowData[rowIndex][0]}"></xp:text>
The error is:
Unknown member '0' in Java class 'java.lang.String'
Any ideas on how I can fix this?
Upvotes: 0
Views: 253
Reputation: 2528
I feel that this can - no should! - be simplified. The basic idea is that you can either feed a Domino view datasource or your entire NotesViewEntryCollection
object as it is into your repeat
object. This way you end up with rowData
representing a single NotesViewEntry
object. Your computedField
value can then directly reference any element from the entry's columnValues
Vector. This way you don't even need to bother recycling any objects:
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoView var="myView" viewName="CatalogEntries" keys=compositeData.catalog keysExactMatch="true">
</xp:dominoView>
</xp:this.data>
<xp:repeat id="repeat1" rows="30" var="rowData" value="#{myView}">
<xp:panel id="pnInner">
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:
if(rowData){
return rowData.getColumnValues()[0].toString();
}else{
return "empty";
}}]]>
</xp:this.value>
</xp:text>
</xp:panel>
</xp:repeat>
</xp:view>
Filtering of your view data is done at the datasource level.
Upvotes: 2
Reputation: 1503
In your push method you do not pass in the array index.
columnVals.push(entry.getColumnValues()[0]);
should be
columnVals.push(entry.getColumnValues());
Howard
Upvotes: 0