Generating downloadable content
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
, toRaceService
Added a new
getCSVContent
method toRaceSummaryController
Added a new
racesummaryascsv
Visualforce pageAdded 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
method introduced in the previous chapter. Here is the new controller method calling it:
public String getCSVContent...