Create Use Custom Controllers
生活随笔
收集整理的這篇文章主要介紹了
Create Use Custom Controllers
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
這兩個(Visualforce頁面和Apex控制器)仍相互鏈接
?
ContactsListController.apxc?
public class ContactsListController {private String sortOrder = 'LastName';public void sortByLastName() {this.sortOrder = 'LastName';}public void sortByFirstName() {this.sortOrder = 'FirstName';}public List<Contact> getContacts() {List<Contact> results = Database.query('SELECT Id, FirstName, LastName, Title, Email ' +'FROM Contact ' +'ORDER BY ' + sortOrder + ' ASC ' +'LIMIT 10');return results;} }ContactsListController.vfp?
<apex:page controller="ContactsListController"><apex:form><apex:pageBlock title="Contacts List" id="contacts_list"><!-- Contacts List --><apex:pageBlockTable value="{! contacts }" var="ct"><apex:column value="{! ct.FirstName }"><apex:facet name="header"><apex:commandLink action="{! sortByFirstName }" reRender="contacts_list">First Name</apex:commandLink></apex:facet></apex:column><apex:column value="{! ct.LastName }"><apex:facet name="header"><apex:commandLink action="{! sortByLastName }" reRender="contacts_list">Last Name</apex:commandLink></apex:facet></apex:column><apex:column value="{! ct.Title }"/><apex:column value="{! ct.Email }"/></apex:pageBlockTable><!-- Contacts List goes here --></apex:pageBlock></apex:form> </apex:page>Create a Visualforce page displaying new cases
NewCaseListController.apxc
public class NewCaseListController {public list<case> getNewCases() {list<case> newcase = new list<case>();newcase = [Select ID,CaseNumber from case where status='New'];return newcase;} }NewCaseList.vfp
<apex:page controller="NewCaseListController"><apex:repeat var="case" value="{!NewCases}"><li><apex:outputLink value="/{!case.id}">{!case.id}</apex:outputLink>{!case.CaseNumber}</li> </apex:repeat> </apex:page> 《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的Create Use Custom Controllers的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Use Standard Control
- 下一篇: Get Started with Ape