The contentType attribute allows you to control how the browser interprets the page output; with this attribute, you can, for example, output some CSV, JSON, or XML content. Using a controller binding, this can be dynamically generated output. This can be useful to generate content to download. The following changes have been made to the FormulaForce application and are included in the code for this chapter:
- Added a new method, generateSummaryAsCSV, to RaceService
- Added a new getCSVContent method to RaceSummaryController
- Added a new racesummaryascsv Visualforce page
- Added a new Custom Button, Download Summary, to the Race layout
The new method is added to the existing RaceSummaryController class, but is only used by the new page. Feel free to review the new Service method; note that it also uses the ContestantsSelector.selectByRaceIdWithContestantSummary...