function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
drewpiston.ax678drewpiston.ax678 

apex:repeat not rendering first record correctly

I'm trying to create a vforce page that lists select activities one after another, similar to the "View All" notes and attachments page.

 

I'd like to put each record in a pageblocksection, but the first one never renders correctly:

 

http://screencast.com/t/NGI4ZjMwNTct

 

Here's my page:

 

 

<apex:page standardController="Contact" extensions="ContactRelatedListController" title="View All Completed Activities">
    <table border="0" >
    	<apex:sectionHeader title="View All Completed Activities" />
	    <apex:repeat value="{!AllClosedTasks}" var="act">
			<apex:pageBlock >
		        <apex:pageBlockSection columns="1">
		            <apex:outputfield value="{!act.Subject}"/>
		            <apex:outputfield value="{!act.WhatId}"/>
		            <apex:outputfield value="{!act.ActivityDate}"/>
		            <apex:outputfield value="{!act.OwnerId}"/>
		            <apex:outputfield value="{!act.Type}"/>
		            <apex:outputfield value="{!act.Description}"/>
				</apex:pageBlockSection>
			</apex:pageBlock>
		</apex:repeat> 
    </table>
</apex:page>

 

 

and here are the relevant parts of my controller:

 

 

public class ContactRelatedListController {
    private final Contact cont;
    
    private final List<Task> closedTasks;
    private final List<Task> allClosedTasks;
    private final String completedActivitiesNumber;
    private final String massEmailNumber;

    public ContactRelatedListController(ApexPages.StandardController stdController) {
        this.cont = (Contact)stdController.getRecord();
        this.closedTasks = new List<Task>([
        	select Id, Subject, WhatId, ActivityDate, WhoId, Type, OwnerId, Description
        	from Task where WhoId = :cont.Id and IsClosed = true
			order by ActivityDate desc]);
    }
    
	public List<Task> getClosedTasks() {
		List<Task> x = new List<Task>();
		for (Task e : this.closedTasks) {
			if (!e.Subject.startsWith('Mass Email:') && x.size() < 5){
				x.add(e);
			}
		}
		return x;
	}
	
	public List<Task> getAllClosedTasks() {
		List<Task> x = new List<Task>();
		for (Task e : this.closedTasks) {
			if (!e.Subject.startsWith('Mass Email:')){
				x.add(e);
			}
		}
		return x;
	}

 

 

Any thoughts?

 

Thanks,

 Drew

 

Best Answer chosen by Admin (Salesforce Developers) 
SargeSarge

Hi,

 

   you should specify row and data cell tag for your table.Reposting your vf code

 

<apex:page standardController="Contact" extensions="ContactRelatedListController" title="View All Completed Activities">
    <table border="0" ><tr><td>
    	<apex:sectionHeader title="View All Completed Activities" />
	    <apex:repeat value="{!AllClosedTasks}" var="act">
			<apex:pageBlock >
		        <apex:pageBlockSection columns="1">
		            <apex:outputfield value="{!act.Subject}"/>
		            <apex:outputfield value="{!act.WhatId}"/>
		            <apex:outputfield value="{!act.ActivityDate}"/>
		            <apex:outputfield value="{!act.OwnerId}"/>
		            <apex:outputfield value="{!act.Type}"/>
		            <apex:outputfield value="{!act.Description}"/>
				</apex:pageBlockSection>
			</apex:pageBlock>
		</apex:repeat> 
    </td></tr></table>
</apex:page>

 

 

Hope this helps.

 

Just one thing. Is the html table component really necessary??? From what I see, you can still show the required things without table html tag.

 

 

 

 

All Answers

SargeSarge

Hi,

 

   you should specify row and data cell tag for your table.Reposting your vf code

 

<apex:page standardController="Contact" extensions="ContactRelatedListController" title="View All Completed Activities">
    <table border="0" ><tr><td>
    	<apex:sectionHeader title="View All Completed Activities" />
	    <apex:repeat value="{!AllClosedTasks}" var="act">
			<apex:pageBlock >
		        <apex:pageBlockSection columns="1">
		            <apex:outputfield value="{!act.Subject}"/>
		            <apex:outputfield value="{!act.WhatId}"/>
		            <apex:outputfield value="{!act.ActivityDate}"/>
		            <apex:outputfield value="{!act.OwnerId}"/>
		            <apex:outputfield value="{!act.Type}"/>
		            <apex:outputfield value="{!act.Description}"/>
				</apex:pageBlockSection>
			</apex:pageBlock>
		</apex:repeat> 
    </td></tr></table>
</apex:page>

 

 

Hope this helps.

 

Just one thing. Is the html table component really necessary??? From what I see, you can still show the required things without table html tag.

 

 

 

 

This was selected as the best answer
drewpiston2drewpiston2

Thanks Sarge!  Getting rid of the table tag did it... you're a genius.

 

Thanks again,

 Drew