Visualforce Custom Controller List

apex-codesalesforcevisualforce

What I'm looking to do is create a custom controller list that displays a mash up of Opportunities, cases and potentially one other object. I started using the class from the visualforce guide to get me going:

public with sharing class CasePagination {
private final Case c;

public CasePagination(ApexPages.StandardSetController controller) {
this.c = (Case)controller.getRecord();
}
public ApexPages.StandardSetController CaseRecords{
get {
if(CaseRecords == null) {
return new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT c.CaseNumber, c.AccountId, c.Subject, c.Status FROM Case c]));
}
return CaseRecords;
}
private set;
}
public List<Case> getCasePagination() {
return (List<Case>) CaseRecords.getRecords();
}
}

I adapted some visualforce code to display a list of cases for now:

<apex:page standardController="Case" recordSetvar="cases" extensions="CasePagination">

<apex:pageBlock title="Viewing Cases">
<apex:form id="theForm">

<apex:pageBlockTable value="{!CasePagination}" var="c">
<apex:outputLink value="{!c.Id}">{!c.CaseNumber}</apex:outputLink>
<apex:column value="{!c.Id}"/>
<apex:column value="{!c.CaseNumber}" />
<apex:column value="{!c.Subject}" onclick="openCase"/>
<apex:column value="{!c.Status}" onclick="openCase"/>
</apex:pageBlockTable>

<apex:panelGrid columns="2">
</apex:panelGrid>
</apex:form>
</apex:pageBlock>
</apex:page>

What I'm trying to do now is make the items in the table clickable. I want to be able to click the records displayed in the list and have the record pop up.

Thanks.

Best Answer

You could use an outputLink:

<apex:pageBlockTable value="{!CasePagination}" var="c">
    <apex:column value="{!c.Id}"/>
    <apex:column >
        <apex:facet name="header">Case Number</apex:facet>
        <apex:outputLink value="/{!c.Id}">{!c.CaseNumber}</apex:outputLink>
    </apex:column>
    <apex:column value="{!c.Subject}" onclick="openCase"/>
    <apex:column value="{!c.Status}" onclick="openCase"/>
</apex:pageBlockTable>