Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <apex:selectList value="{!reportYear}" label="" size="1" id="selectedReportYear">
- <apex:selectOptions value="{!yearOptions}"/>
- </apex:selectList>
- /**
- * @description This returns a list of years
- **/
- public List<SelectOption> getYearOptions() {
- List<SelectOption> options = new List<SelectOption>();
- // Get the current year
- Integer optionYear = System.Today().year();
- // Add an option for this year and the previous two years
- for (Integer i=0;i<=2;i++) {
- // Get the year as a string
- String optionYearStr = String.valueOf(optionYear);
- // Add this to the list
- options.add(new SelectOption(optionYearStr,optionYearStr));
- // Decrement the year
- optionYear--;
- }
- return options;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement