Search Pages
Example 1: Search in Lead
- <apex:page controller="ourLeadController" >
- <apex:form >
- <apex:pageblock >
- <apex:inputtext value="{!searchText}"/>
- <apex:commandButton value="Perform Search" action="{!doSearch}" rerender="block"/>
- </apex:pageblock>
- <apex:pageblock id="block">
- <apex:pageblocktable value="{!results}" var="l">
- <apex:column value="{!l.name}"/>
- <apex:column value="{!l.phone}"/>
- <apex:column value="{!l.email}"/>
- </apex:pageblocktable>
- </apex:pageblock>
- </apex:form>
- </apex:page>
- public with sharing class ourLeadController {
- String thetext;
- list<lead> results;
- public List<lead> getResults(){
- return results;
- }
- public pageReference doSearch(){
- results = (list<lead>)[find: thetext returning lead(name, phone, email)][0];
- return null;
- }
- public string getsearchtext(){
- return null;
- }
- public void setsearchtext(string s){
- thetext=s;
- }
- }
Example 2: snippet
List<List<SObject>> searchList= [FIND 'map*' IN NAME FIELDS RETURNING Account (id, name),Contact];
Account [ ] accounts= ((List<Account>)searchList[0]);
Contact [ ] contacts= ((List<Contact>)searchList[1]);
Comments
Post a Comment