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
Hannah CampbellHannah Campbell 

i need help with connecting my apex controller with the my visualforce component

Here is my Apex Class:
public class jobApplicationTempt{
    public Id JobApplicationId {get;set;}
    public List<Job_Application__c> getJobApplication(){
        List<Job_Application__c> listOfJobApp;
        listOfJobApp=[SELECT Position__r.Name, Name__c, Phone__c, Email__c From Job_Application__c WHERE status__c = 'Approved' ];
        return listOfJobApp;
    }
}

and this is my VF Component:

<apex:component controller="jobApplicationTempt" access="global">
    <apex:attribute name="JobAppId" type="Id" description="Id of the JobApplication" AssignTo="{!JobApplicationId}"/>
    <table border="2" cellspacing="5">
        <tr>
            <td>Position Name</td>
            <td>Candidate Name</td>
            <td>Candidate Phone</td>
            <td>Candidate Email</td>
        </tr>
        <apex:repeat value="{!JobApplications}" var="o">
        <tr>
            <td>{!o.Position__r.Name}</td>
            <td>{!o.Name}</td>
            <td>{!o.Phone}</td>
            <td>{!o.Email}</td>
        </tr>
        </apex:repeat>
    </table>
</apex:component>

Raj VakatiRaj Vakati
You need to invoke this component from the visualforce page 

<apex:page>

<c:VF_cmponent/>
</apex:page>

 
Hannah CampbellHannah Campbell
im going to invoke the VF component with a VF email template. Would that matter?
Raj VakatiRaj Vakati
No that also will work 
Raj VakatiRaj Vakati
Use this code
 
public class jobApplicationTempt{
    public Id JobApplicationId {get;set;}
    public List<Job_Application__c> getJobApplication(){
        List<Job_Application__c> listOfJobApp;
        listOfJobApp=[SELECT Position__r.Name, Name__c, Phone__c, Email__c From Job_Application__c WHERE status__c = 'Approved' ];
        return listOfJobApp;
    }
}
 
<apex:component controller="jobApplicationTempt" access="global">
    <apex:attribute name="JobAppId" type="Id" description="Id of the JobApplication" AssignTo="{!JobApplicationId}"/>
    <table border="2" cellspacing="5">
        <tr>
            <td>Position Name</td>
            <td>Candidate Name</td>
            <td>Candidate Phone</td>
            <td>Candidate Email</td>
        </tr>
        <apex:repeat value="{!jobApplications}" var="o">
        <tr>
            <td>{!o.Position__r.Name}</td>
            <td>{!o.Name}</td>
            <td>{!o.Phone__c}</td>
            <td>{!o.Email__c}</td>
        </tr>
        </apex:repeat>
    </table>
</apex:component>