Salesforce apex:inputCheckboxの使い方のサンプル
環境
Salesforce
概要
checkbox 型の HTML 入力要素です。このコンポーネントを使用して、Salesforce オブジェクトの項目に対応しないコントローラーメソッドのユーザー入力を取得します。
このコンポーネントを使用して、sObject の項目に対応しな
いコントローラーメソッドのユーザー入力を取得します。
sObject 項目で使用できるのは、<apex:inputField> と
<apex:outputField> のみです。
サンプルコード
<!-- For this example to render properly, you must associate the Visualforce page
with a valid opportunity record in the URL.
For example, if 001D000000IRt53 is the opportunity ID, the resulting URL should be:
https://Salesforce_instance/apex/myPage?id=001D000000IRt53
See the Visualforce Developer's Guide Quick Start Tutorial for more information. -->
<apex:page standardController="Opportunity" recordSetVar="opportunities" tabstyle="opportunity">
<apex:form id="changePrivacyForm">
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons>
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!opportunities}" var="opp">
<apex:column value="{!opp.name}"/>
<apex:column value="{!opp.account.name}"/>
<apex:column headerValue="Private?">
<apex:inputCheckbox value="{!opp.isprivate}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
上述の例では次の HTML を表示します。
<!-- allows you to change the privacy option of your opportunity -->
<form id="j_id0:changePrivacyForm" name="j_id0:changeStatusForm" method="post"
action="/apex/sandbox" enctype="application/x-www-form-urlencoded">
<!-- opening div tags -->
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="pbTitle"> </td>
<td id="j_id0:changePrivacyForm:j_id1:j_id29" class="pbButton">
<input type="submit"
name="j_id0:changePrivacyForm:j_id1:j_id29:j_id30"
value="Save" class="btn"/>
</td>
</tr>
</table>
<div class="pbBody">
<table class="list" border="0" cellpadding="0" cellspacing="0">
<colgroup span="3"/>
<thead>
<tr class="headerRow ">
<th class="headerRow " scope="col">Opportunity Name</th>
<th class="headerRow " scope="col">Account Name</th>
<th class="headerRow " scope="col">Privacy?</th>
</tr>
</thead>
<tbody>
<tr class="dataRow even first ">
<td class="dataCell"><span>Burlington Textiles Weaving Plant Generator</span></td>
<td class="dataCell"><span>Burlington Textiles Corp of America</span></td>
<td class="dataCell"><input type="checkbox" name="j_id0:changePrivacyForm:j_id1:j_id31:0:j_id35" checked="checked" /></td>
</tr>
<tr class="dataRow odd last ">
<td class="dataCell"><span>Edge Emergency Generator</span></td>
<td class="dataCell"><span>Edge Communications</span></td>
<td class="dataCell"><input type="checkbox" name="j_id0:changePrivacyForm:j_id1:j_id31:0:j_id35" checked="checked" /></td>
</tr>
</tbody>
</table>
</div>
<!-- closing div tags -->
</form>