,

Displaying Interviewers

Once again, create the final page of your wizard in the controller code.

This time, add two new elements to your controller code, and handle them slightly differently in your Visualforce page.

1.
Return to edit the custom controller through the Setup Develop Apex Code choice, and then click Edit for the controller class.

2.
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.

3.
Return to your controller code and edit the step3 navigation method to point to this third page. Once you save the third page as wizard3, the completed method looks like this:

public PageReference step3() {
        return Page.wizard3;
    }

4.
Run your wizard from the first page to the last to see how it flows. The third page, with data, should look like the figure below.

Figure 198. The third page of your Visualforce wizard


You have now implemented the user interface portion of your wizard, along with the custom controller code to make them work nicely together. Your last task is to complete the work that your user specified with the wizard by saving the interviews with their date and time.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.197.221