+ Start a Discussion

Detect first/last row in repeater?

How can I detect one without having to write a wrapper class carrying such indicator?


In general, how do you create JSON array using visualforce in regards to the ommission of last comma? For example, I currently use this approach:


<apex:page standardController="Case" extensions="extension_Timeline" contentType="text/javascript" showHeader="false" sidebar="false">
{ "data" : [ 
	<apex:repeat value="{!allItems}" var="item">
		<apex:outputText value="," rendered="{!NOT(item.firstItem)}" />
			"Type": "{!item.ItemType}",
			"dateTime": "{!item.DateTime}",
			"userName": "{!item.UserName}",
			"content": "{!JSENCODE(item.Content)}",
			"FullContent": "{!JSENCODE(item.FullContent)}"


 however, this approach forces me to "repack" the SOQL List<SObject> into List<MyCustomWrapperWithFirstRowIndicator> which is a pain and wastes resources. Any other approach I might be missing?