Apex Class:
public class SearchLeads {
public Lead newLead {get;set;}
public list<lead> leadList {get;set;}
public SearchLeads () {
newLead = new Lead();
}
public list<lead> doSearch() {
leadList =[select id,name,Status from lead where status =: newLead.status];
return null;
}
}
Visualforce Page :
<apex:page controller="SearchLeads">
<apex:form >
Staus : <apex:inputField value="{!newLead.status}"/>
<apex:commandButton value="Search" action="{!doSearch}"/>
<apex:pageBlock title="List of Leads">
<apex:pageBlockTable value="{!leadList}" var="item">
<apex:column value="{!item.name}"/>
<apex:column value="{!item.status}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
output :
public class SearchLeads {
public Lead newLead {get;set;}
public list<lead> leadList {get;set;}
public SearchLeads () {
newLead = new Lead();
}
public list<lead> doSearch() {
leadList =[select id,name,Status from lead where status =: newLead.status];
return null;
}
}
Visualforce Page :
<apex:page controller="SearchLeads">
<apex:form >
Staus : <apex:inputField value="{!newLead.status}"/>
<apex:commandButton value="Search" action="{!doSearch}"/>
<apex:pageBlock title="List of Leads">
<apex:pageBlockTable value="{!leadList}" var="item">
<apex:column value="{!item.name}"/>
<apex:column value="{!item.status}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
output :