Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. <apex:page standardController="Console__c" extensions="ConsoleNewController" sideBar="true">
  2. <apex:pageMessages id="pageMessages"/>
  3.  
  4. <apex:form>
  5. <apex:pageBlock mode="maindetail">
  6. <apex:pageBlockSection columns="1">
  7. <apex:pageBlockSectionItem>
  8. <apex:outputLabel value="{!$ObjectType.Console__c.fields.Type__c.Label}" for="consoleTypeSelectList"/>
  9. <apex:selectList value="{!Console__c.Type__c}" size="1" required="true" id="consoleTypeSelectList">
  10. <apex:selectOptions value="{!consoleTypes}"/>
  11. </apex:selectList>
  12. </apex:pageBlockSectionItem>
  13. <apex:pageBlockSectionItem>
  14. <apex:outputLabel value="{!$ObjectType.Console__c.fields.Year__c.Label}" for="consoleYearSelectList"/>
  15. <apex:selectList value="{!Console__c.Year__c}" size="1" required="true" id="consoleYearSelectList">
  16. <apex:selectOptions value="{!consoleYears}"/>
  17. </apex:selectList>
  18. </apex:pageBlockSectionItem>
  19. </apex:pageBlockSection>
  20. </apex:pageBlock>
  21. <apex:commandButton value="Save" action="{!save}" status="status" id="saveButton"/>
  22. <apex:commandButton value="Cancel" action="!cancel" id="cancelButton"/>
  23. </apex:form>
  24. </apex:page>
  25.  
  26. public with sharing class ConsoleNewController
  27. {
  28. public ApexPages.StandardController standardController;
  29. private Console__c console;
  30. private List<SelectOption> consoleTypes { get; private set; }
  31. private List<SelectOption> consoleYears { get; private set; }
  32.  
  33. public ConsoleNewController(ApexPages.StandardController controller)
  34. {
  35. this.standardController = controller;
  36. this.console = (Console__c) controller.getRecord();
  37. this.consoleTypes = getConsoleTypes();
  38. this.consoleYears = getConsoleYears();
  39. }
  40.  
  41. public List<SelectOption> getConsoleTypes()
  42. {
  43. List<String> types = new List<String> {'PlayStation', 'Xbox', 'Nintendo', 'Atari', 'Sega'};
  44. List<SelectOption> typelist = new List<SelectOption>();
  45. typelist.add(new SelectOption('', 'None'));
  46.  
  47. for (String type : types)
  48. {
  49. typelist.add(new SelectOption(type, type));
  50. }
  51.  
  52. return typelist;
  53. }
  54.  
  55. public List<SelectOption> getConsoleYears()
  56. {
  57. List<SelectOption> yearList = new List<SelectOption>();
  58. yearList.add(new SelectOption('', 'None'));
  59.  
  60. for (Integer i = 2001; i < 2018; i++)
  61. {
  62. String value = String.valueOf(i);
  63. yearList.add(new SelectOption(value, value));
  64. }
  65. return yearList;
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement