Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <apex:selectList value="{!reportYear}" label="" size="1" id="selectedReportYear">
  2. <apex:selectOptions value="{!yearOptions}"/>
  3. </apex:selectList>
  4.  
  5. /**
  6. * @description This returns a list of years
  7. **/
  8. public List<SelectOption> getYearOptions() {
  9. List<SelectOption> options = new List<SelectOption>();
  10.  
  11. // Get the current year
  12. Integer optionYear = System.Today().year();
  13.  
  14. // Add an option for this year and the previous two years
  15. for (Integer i=0;i<=2;i++) {
  16. // Get the year as a string
  17. String optionYearStr = String.valueOf(optionYear);
  18.  
  19. // Add this to the list
  20. options.add(new SelectOption(optionYearStr,optionYearStr));
  21.  
  22. // Decrement the year
  23. optionYear--;
  24.  
  25. }
  26.  
  27. return options;
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement