• Rufus wall
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I am trying to teach myself Apex, so I've come up with a project to create and am figuring it out step-by-stumbling-step. Here is the step I am stuck on.

Here is my goal: I want a page that shows you a list of records in a table. When you click the name of one of the records, the whole list disappears and you see a page showing information from that record.

Here's my code so far which is not working. It's a page which loads the two separate pages, and decides which one to render based on whether a certain variable (the selected record id) is null or not.

Controller:
public class testController {
    public id gameId{get; set;}
    
    public List<Game__c> getGames() {
    	List<Game__c> results = Database.query(
        	'SELECT id,name,owner.name,LastModifiedDate FROM game__c'
        );
        return results;
    }
}

Page 1:
<apex:page showheader="true" controller="testController">
    <apex:include pageName="listPage" rendered="{! ISNULL( gameId ) }"/>
    <apex:include pageName="detailPage" rendered="{! NOT( ISBLANK( gameId )) }"/>
</apex:page>
listPage:
<apex:page showHeader="false" controller="testController" id="display">

        <apex:form >
            <apex:pageblock >
                <apex:pageblocktable value="{! games}" var="g">                   
                    
                    <apex:column headerValue="Name">
                        <apex:commandLink value="{!g.Name}" rerender="display" >
                            <apex:param assignTo="{!gameId}" name="{!g.Id}" value="{!g.Id}"/>
                        </apex:commandLink>
                    </apex:column>

                </apex:pageblocktable>
           </apex:pageblock>
       </apex:form>
</apex:page>

detailPage:
<apex:page showHeader="false" controller="testController">    
    <apex:outputtext value="test" />
</apex:page>
Expected behavior: I click the the name of the any of the Game records in the list on the listPage and the whole list disappears and is replaced with a blank white screen and the word "test".
Actual results: Clicking the name does nothing.

Am I on the right track trying to do this with three separate pages? Or should this all be handled in one visualforce page?