Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search

Available in the Appstore!All the content of xpageswiki.com for iPhone or iPad for offline access.

Home > Controls > Work with repeat controls

Work with repeat controls

ShowTable of Contents

Repeat control with the result of a JavaScript or the content of a document field


Set CollectionName to "data" and Index to "index" in your repeat control.
Set DataBinding to JavaScript.

Example: get a list/array out of a field stored in a profile document.

var profile:NotesDocument = database.getProfileDocument("DBConfig", "");
profile.getItemValue("somefield")


Inside the Repeat Control each value is in the variable "data". Don't work with .getColumnValue() like in repeat controls based on a view.

get the count of repeat control


Give your repeat control an id, for example "myRepeatControl".
Then you can use

getComponent("myRepeatControl").getRowCount();


This works inside and outside the repeat control.

repeat control inside another repeat control


Assume you have a view "contacts" containing contact documents, and another view "notes" which contains note documents for these contacts. The note documents have a field "parentDocUNID" in which the UNID of the parent contact is saved.

The "contacts" has at least these columns:
- "name"
- "unid" (with @Text(@DocumentUniqueID) )

The "notes" view has at least these columns:
- "parentDocUNID" with the UNID of the note parent contact document
- "title" with the title of the note

You want to display the contacts, and below each contact all relating note documents:

1.) Place a repeat control on your XPage and connect it with a datasource for the "contacts" view.

2.) In this repeat control set "contactData" as collectionName.

3.) Inside this repeat control place a label computed value "contactData.getColumnValue("name")" or something similar (if the contacs view contains a column "name").

4.) Inside this repeat control place another repeat control with "noteData" as collectionName and for example this code:

var tview = database.getView("notes");
var v = contactData.getColumnValue("unid");
var vc:NotesViewEntryCollection = null;
if (v != null) {
	vc = tview.getAllEntriesByKey(v);
}
vc


Inside your second repeat control the variable "noteData" contains NotesViewEntry objects from the "vc" result of the code.
So you can place a label inside the second repeat control with for example this computed value:

noteData.getColumnValues()[1]


to get the value of the second column of the note view.

Set HTML header and footer


Since 8.5.1 you can define leading and trailing HTML in the repeat control. For example this is useful in lists, where you have <ul><li>...<li></ul> elements. The <li> elements are created by the repeat control, and you want the <ul>..</ul> right before and after the <li> items.

For that you can add two facets manually in the XPages source code, after the <xp:repeat...> element:

 <xp:this.facets>
                         
             <xp:text disableTheme="true" xp:key="header" escape="false">
             <xp:this.value><![CDATA<ul>]]></xp:this.value>
             </xp:text>

             <xp:text disableTheme="true" xp:key="footer" escape="false">
             <xp:this.value><![CDATA</ul>]]></xp:this.value>
             </xp:text>                

     </xp:this.facets>             


Full example code:

<xp:repeat id="repeat1" rows="30" value="#{view1}" var="repeat1">
             
     <xp:this.facets>
                         
             <xp:text disableTheme="true" xp:key="header" escape="false">
             <xp:this.value><![CDATA<ul>]]></xp:this.value>
             </xp:text>

             <xp:text disableTheme="true" xp:key="footer" escape="false">
             <xp:this.value><![CDATA</ul>]]></xp:this.value>
             </xp:text>                

     </xp:this.facets>                
             
     <li><xp:text escape="true" id="name">
             <xp:this.value><![CDATA[#{javascript:repeat1.getColumnValue("name")}]]></xp:this.value>
     </xp:text>
     </li>
</xp:repeat> 


Taken from Domino Wiki
Created by Anonymous on Sep 24, 2009 8:37:05 PM

noteData.getColumnValues()[1} <-- last brace should be square bracket.


Created by Julian Buss on Oct 12, 2009 9:47:39 AM

corrected - thanks!


Created by Anonymous on Jun 4, 2010 7:14:41 AM


Add Comment

Name:
Comments:
Use  searchlotus.com  for news in the Web related to Lotus Notes and Domino,
and to search those sites.
Check  youatnotes.com  for great Lotus Notes, Domino and XPages software.
Did this information help you?
Please honor our efforts and flattr this!