Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <apex:page standardController="Console__c" extensions="ConsoleNewController" sideBar="true">
- <apex:pageMessages id="pageMessages"/>
- <apex:form>
- <apex:pageBlock mode="maindetail">
- <apex:pageBlockSection columns="1">
- <apex:pageBlockSectionItem>
- <apex:outputLabel value="{!$ObjectType.Console__c.fields.Type__c.Label}" for="consoleTypeSelectList"/>
- <apex:selectList value="{!Console__c.Type__c}" size="1" required="true" id="consoleTypeSelectList">
- <apex:selectOptions value="{!consoleTypes}"/>
- </apex:selectList>
- </apex:pageBlockSectionItem>
- <apex:pageBlockSectionItem>
- <apex:outputLabel value="{!$ObjectType.Console__c.fields.Year__c.Label}" for="consoleYearSelectList"/>
- <apex:selectList value="{!Console__c.Year__c}" size="1" required="true" id="consoleYearSelectList">
- <apex:selectOptions value="{!consoleYears}"/>
- </apex:selectList>
- </apex:pageBlockSectionItem>
- </apex:pageBlockSection>
- </apex:pageBlock>
- <apex:commandButton value="Save" action="{!save}" status="status" id="saveButton"/>
- <apex:commandButton value="Cancel" action="!cancel" id="cancelButton"/>
- </apex:form>
- </apex:page>
- public with sharing class ConsoleNewController
- {
- public ApexPages.StandardController standardController;
- private Console__c console;
- private List<SelectOption> consoleTypes { get; private set; }
- private List<SelectOption> consoleYears { get; private set; }
- public ConsoleNewController(ApexPages.StandardController controller)
- {
- this.standardController = controller;
- this.console = (Console__c) controller.getRecord();
- this.consoleTypes = getConsoleTypes();
- this.consoleYears = getConsoleYears();
- }
- public List<SelectOption> getConsoleTypes()
- {
- List<String> types = new List<String> {'PlayStation', 'Xbox', 'Nintendo', 'Atari', 'Sega'};
- List<SelectOption> typelist = new List<SelectOption>();
- typelist.add(new SelectOption('', 'None'));
- for (String type : types)
- {
- typelist.add(new SelectOption(type, type));
- }
- return typelist;
- }
- public List<SelectOption> getConsoleYears()
- {
- List<SelectOption> yearList = new List<SelectOption>();
- yearList.add(new SelectOption('', 'None'));
- for (Integer i = 2001; i < 2018; i++)
- {
- String value = String.valueOf(i);
- yearList.add(new SelectOption(value, value));
- }
- return yearList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement