Add the following code to the controller class:
public Interview__c intDate {
get {
if(intDate == null) {
intDate = new Interview__c();
}
return intDate;
}
set;
}
public List<Interview__c> jobApplicationInterviewers {
get {
if(jobApplicationInterviewers == null) {
jobApplicationInterviewers =
[select Interview__c.ID, Interviewer__r.Name,
Interview__c.Interview_Date__c,
Interview__c.Interview_Time__c
from Interview__c
where Job_Application__r.ID =
:selectedJobApplication];
}
return jobApplicationInterviewers;
}
set;
}
Once again, you add two new variables to the controller code. The first is an instance of the Interview__c object. You use this to hold a value for the date of the scheduled interviews. Since the value entered for this date is added to all the interview records, you do not want to bind the
inputField on the Visualforce page to the collection of Interview__c records. As with the earlier property, this property performs an
if test to determine if initialization is needed.
The second variable declares and populates that collection of Interview__c records that are related to the candidate for the position chosen on the previous page. The ID for the Job Application record is the value of the ID chosen in the selectList on the second page of the wizard, as it should be.
With these changes, you are ready to add the final Visualforce page for your wizard. The code for this page is shown below, and was loaded into your organization under the name of
wizard3 with the initialization script for this chapter:
<apex:page controller="customController">
<apex:sectionHeader title="Interview Scheduler"
subtitle="Step 3 of 3 - Schedule interview times"/>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:pageBlockTable
value="{!jobApplicationInterviewers}" var="int">
<apex:column headervalue="Interviewer"
value="{!int.Interviewer__r.Name}"/>
<apex:column headervalue="Interview Time">
<apex:inputField
value="{!int.Interview_Time__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel
value="Date for interviews:"/>
<apex:inputField
value="{!intDate.Interview_Date__c}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageblockButtons location="bottom">
<apex:commandButton action="{!Save}"
value="Save"/>
</apex:pageblockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
This Visualforce page is slightly more complex than the previous pages. There are two
pageBlockSections: one to hold the display of Interviewers in a
pageBlockTable and another to specify the date for al the interviews. This paricular implementation assumes that all interviews will be conducted on the same day, so a user can specify a date once for all the interviews. The code you create for your save method adds this value to all of the interviews listed in this page.