using custom label in visualforce page

A custom label can used to store a desired text value of length up to 1000. A custom label value can then be referenced by apex code or visualforce page. A custom label can store values of length up to 1000 characters in it. We can have a total of 5000 custom labels in an org.
Create a custom label by navigating to set up -> create -> custom label

In the below example let us see how we can access the custom label in visualforce page directly.

Visualforce page that accesses the custom label 

<apex:page controller="custlabelcontroller">
   <apex:form >
     <apex:pageblock >
       Value stored in custom label is: {!$Label.category}
     </apex:pageblock>
   </apex:form>

</apex:page>



call batch apex from trigger

A batch apex can be called from a class as well as from trigger code. But, we have to be very very carefull while calling a batch apex from trigger.

Batch apex

global class BatchApexDemo implements database.batchable<sobject>{
Public string soqlquery;
 Public void setQry(string soqlquery){
    this.soqlquery = 'Select name,status from account limit 1';  
 }
 global database.querylocator start(database.batchableContext bc){
   return database.getquerylocator(soqlquery);
 }
 global void execute(database.batchablecontext bd, list<sObject> sc){
   System.debug('**In Execute Method**');  
 }
 Public void finish(database.batchableContext bc){ 
 }
}


Trigger

trigger callbatchapex on Account (after insert) {
 List<account> accList = new List<account>();
 for(account acc : trigger.new){
     if(acc.annualrevenue < 20000)
        accList.add(acc); 
 }
    if(accList.size() > 0)
      database.executebatch(new BatchApexDemo(),200);
}