Created
June 11, 2015 11:46
-
-
Save tyoshikawa1106/e1ed8aff6a65a066dea6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page controller="PicklistEntryDemoController" sidebar="false" tabStyle="Account"> | |
<apex:form > | |
<apex:pageBlock > | |
<apex:pageBlockSection columns="2"> | |
<apex:pageBlockSection columns="1" title="選択リスト値取得"> | |
<apex:outputPanel > | |
<ul> | |
<apex:repeat value="{!selectList}" var="item"> | |
<li><apex:outputText value="{!item}" /></li> | |
</apex:repeat> | |
</ul> | |
</apex:outputPanel> | |
</apex:pageBlockSection> | |
<apex:pageBlockSection columns="1" title="複数選択リスト値取得"> | |
<apex:outputPanel > | |
<ul> | |
<apex:repeat value="{!multiselectList}" var="item"> | |
<li><apex:outputText value="{!item}" /></li> | |
</apex:repeat> | |
</ul> | |
</apex:outputPanel> | |
</apex:pageBlockSection> | |
</apex:pageBlockSection> | |
</apex:pageBlock> | |
</apex:form> | |
</apex:page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class PicklistEntryDemoController { | |
public List<String> selectList {get; set;} | |
public List<String> multiselectList {get; set;} | |
public PicklistEntryDemoController() { | |
// 初期化 | |
this.selectList = new List<String>(); | |
this.multiselectList = new List<String>(); | |
// 選択リスト値取得 | |
Schema.DescribeFieldResult ratingFidldResult = Account.Rating.getDescribe(); | |
List<Schema.PicklistEntry> ratingPicklistEntry = ratingFidldResult.getPicklistValues(); | |
for (Schema.PicklistEntry pick : ratingPicklistEntry) { | |
this.selectList.add('Label = ' + String.valueOf(pick.getLabel()) + ' : ' + 'Value = ' + String.valueOf(pick.getValue())); | |
} | |
// 複数選択リスト値取得 | |
Schema.DescribeFieldResult multiselectFidldResult = Account.Multiselect__c.getDescribe(); | |
List<Schema.PicklistEntry> multiselectPicklistEntry = multiselectFidldResult.getPicklistValues(); | |
for (Schema.PicklistEntry pick : multiselectPicklistEntry) { | |
this.multiselectList.add('Label = ' + String.valueOf(pick.getLabel()) + ' : ' + 'Value = ' + String.valueOf(pick.getValue())); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment