Sunday, June 2, 2013

How to write Batch Apex along with Visualforce page?

Batch Apex with Visualforce

Visualforce Controller Code:
public class RunBatchController{
public void RunBatch(){
// DeletionBatch is the batch you implemented.
DeletionBatch batch = new DeletionBatch();
Database.executeBatch(batch);
}
}

Visualforce Page Code:
<apex:page controller="RunBatchController">
   <apex:commandButton action="{!RunBatch}" value="Delete Records"/>
</apex:page>