Hi All,
This is a cool post for me.Here I have created one page where you can search many sfdc component(apex class,vf pages, user,report,approval process, trigger).
Useful for Whom ?
We can search these component as below image.if you want to search more than add that component in options list rest will be take care.
Here is the Page:-
<apex:page controller="SearchApexComponent">
<apex:form >
<apex:pageBlock title="Find Your SFDC Component" id="pblock">
<apex:pageMessages id="message"></apex:pageMessages>
<apex:outputLabel value="Choose Search Item">
<apex:selectList value="{!objectname}" size="1" multiselect="false">
<apex:selectOptions value="{!options }" >
</apex:selectOptions>
</apex:selectList>
</apex:outputLabel>
<apex:outputLabel value="Enter Name" for="txt"></apex:outputLabel>
<apex:inputText value="{!inputString}" id="txt"/>
<apex:commandButton value="Search" action="{!Showclasses}" reRender="pbt,message,pblock"/>
<apex:pageBlockTable value="{!Classes}" var="cls" id="pbt">
<apex:column headerValue=" Name">
<apex:commandLink action="{!Go}" target="_blank">
<apex:param name="clsid" value="{!cls['id']}"/>
<apex:outputField value="{!cls['name']}"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue=" Created By">
<apex:outputField value="{!cls['CreatedByid']}"/>
</apex:column>
<apex:column headerValue=" Modified By">
<apex:outputField value="{!cls['LastModifiedByid']}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Here is Controller :-
public with sharing class SearchApexComponent {
public String inputString{get;set;}
public String objectname{get;set;}
public List<sObject> Classes{get;set;}
string classId;
public List<SelectOption> options{get;set;}
public SearchApexComponent(){
Classes = new List<sObject>();
options = new List<SelectOption>();
options.add(new selectOption('','--None--'));
options.add(new selectOption('ApexClass','ApexClass'));
options.add(new selectOption('ApexPage','VisualForce Page'));
options.add(new selectOption('ApexTrigger','Trigger'));
options.add(new selectOption('Approval','Approval Process'));
options.add(new selectOption('User','User'));
options.add(new selectOption('Document','Document'));
options.add(new selectOption('Profile','Profile'));
options.add(new selectOption('PermissionSet','PermissionSet'));
options.add(new selectOption('Report','Report'));
}
public PageReference Showclasses(){
system.debug('printing claaneem---'+Objectname );
if(Objectname ==null || Objectname == '' || Objectname == '--None--'){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please choose component what you want to search');
ApexPages.addMessage(myMsg);
return null;
}
else if(inputString ==null || inputString == ''){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please Enter Some Input String');
ApexPages.addMessage(myMsg);
}
else{
String sQuerry = 'select id,name,CreatedByid,LastModifiedById from '+Objectname +' where name LIKE '+'\'%'+inputString+'%\''+'LIMIT 100';
System.debug('Print sQuerry -->'+sQuerry );
classes = Database.query(sQuerry );
}
system.debug('printing Classes list---'+Classes);
return null;
}
public PageReference Go(){
classId = Apexpages.currentpage().getparameters().get('clsid');
PageReference requestPage = new pagereference('https://cs1.salesforce.com/'+classId);
requestPage.setRedirect(true);
return requestPage;
}
}
This is a cool post for me.Here I have created one page where you can search many sfdc component(apex class,vf pages, user,report,approval process, trigger).
Useful for Whom ?
- All developers who always try to finish work as son as possible.
- Don't want click on Next & Prev link to reach at particular component(if more than 100 is there).
- Want to get all different component in one page.
- The best thing is with in less time to get component.
We can search these component as below image.if you want to search more than add that component in options list rest will be take care.
Here is the Page:-
<apex:page controller="SearchApexComponent">
<apex:form >
<apex:pageBlock title="Find Your SFDC Component" id="pblock">
<apex:pageMessages id="message"></apex:pageMessages>
<apex:outputLabel value="Choose Search Item">
<apex:selectList value="{!objectname}" size="1" multiselect="false">
<apex:selectOptions value="{!options }" >
</apex:selectOptions>
</apex:selectList>
</apex:outputLabel>
<apex:outputLabel value="Enter Name" for="txt"></apex:outputLabel>
<apex:inputText value="{!inputString}" id="txt"/>
<apex:commandButton value="Search" action="{!Showclasses}" reRender="pbt,message,pblock"/>
<apex:pageBlockTable value="{!Classes}" var="cls" id="pbt">
<apex:column headerValue=" Name">
<apex:commandLink action="{!Go}" target="_blank">
<apex:param name="clsid" value="{!cls['id']}"/>
<apex:outputField value="{!cls['name']}"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue=" Created By">
<apex:outputField value="{!cls['CreatedByid']}"/>
</apex:column>
<apex:column headerValue=" Modified By">
<apex:outputField value="{!cls['LastModifiedByid']}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Here is Controller :-
public with sharing class SearchApexComponent {
public String inputString{get;set;}
public String objectname{get;set;}
public List<sObject> Classes{get;set;}
string classId;
public List<SelectOption> options{get;set;}
public SearchApexComponent(){
Classes = new List<sObject>();
options = new List<SelectOption>();
options.add(new selectOption('','--None--'));
options.add(new selectOption('ApexClass','ApexClass'));
options.add(new selectOption('ApexPage','VisualForce Page'));
options.add(new selectOption('ApexTrigger','Trigger'));
options.add(new selectOption('Approval','Approval Process'));
options.add(new selectOption('User','User'));
options.add(new selectOption('Document','Document'));
options.add(new selectOption('Profile','Profile'));
options.add(new selectOption('PermissionSet','PermissionSet'));
options.add(new selectOption('Report','Report'));
}
public PageReference Showclasses(){
system.debug('printing claaneem---'+Objectname );
if(Objectname ==null || Objectname == '' || Objectname == '--None--'){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please choose component what you want to search');
ApexPages.addMessage(myMsg);
return null;
}
else if(inputString ==null || inputString == ''){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please Enter Some Input String');
ApexPages.addMessage(myMsg);
}
else{
String sQuerry = 'select id,name,CreatedByid,LastModifiedById from '+Objectname +' where name LIKE '+'\'%'+inputString+'%\''+'LIMIT 100';
System.debug('Print sQuerry -->'+sQuerry );
classes = Database.query(sQuerry );
}
system.debug('printing Classes list---'+Classes);
return null;
}
public PageReference Go(){
classId = Apexpages.currentpage().getparameters().get('clsid');
PageReference requestPage = new pagereference('https://cs1.salesforce.com/'+classId);
requestPage.setRedirect(true);
return requestPage;
}
}