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
Ivor Jenkins 2Ivor Jenkins 2 

Showing related items in a table in a visualforce page

I have two custom components, Visitor_Hospitality_Form__c and Visitors__c... their is a master-detail relationship between the forms and the visitors.
I have created a Visualforce Compnent, a controller and a visualforce page to show all the related visitors on the visitors form page but it isn't showing any items in the table
Here is the controller
global with sharing class VHF_VisitorsListController {
    global string VHFID {get;set;}
    global List<Visitors__c> existingVisitors {get;set;}
    public VHF_VisitorsListController() {
        existingVisitors = new list<Visitors__c>();
        existingVisitors = [SELECT NAME,Arriving_by_Taxi__c,Email__c,Is_Director__c,Is_WiFi_Required__c,Job_Title__c,Lunch_Required__c,
                            Parking_Space_Required__c,Special_Dietary_Requirements__c
                           FROM Visitors__c  WHERE     Visitor_Hospitality_Form__c = :VHFID];
        
        
    }
}
Here is the component:
<apex:component access="global" controller="VHF_VisitorsListController">
    <apex:attribute name="VHFIDValue" type="String" description="This is the Id of the VHF" assignTo="{!VHFID}" access="global" />
    <table class="table">
        <thead>    
            <tr>
                <th>Name</th> 
                <th>Job Title</th>
            </tr>
        </thead>        
        <tbody>
            
            <apex:repeat value="{!existingVisitors}" var="vis">
                <tr>
                    <td>{!vis.Name}</td>
                    <td>{!vis.Job_Title__c}</td>
                    
                </tr>
            </apex:repeat>            
            
        </tbody>   
    </table>
</apex:component>
Ganesh03Ganesh03
Hi, Did you check if your query is returning the records you're expecting.

I'd start troubleshooting from there. Try to print list 'existingVisitors' after the query execution and let's go from there.

Hope you'll find this helpful ! Cheers ! Keep Sales forcing :-)