Disable Visualforce Buttons When Processing – apex:actionStatus

27 Dec

It is very handy to disable buttons after they have been pressed. This lets the user know that the button was in fact pressed, and it prevents the button’s action from being executed multiple times. The Visulforce component apex:actionStatus gives us an easy way to accomplish this. Here are some things to take note of in the example.

  • The command button must have a rerender parameter
  • Command buttons must be in an apex:outputPanel, so both buttons appear on the page when each apex:facet is active.
  • The action status will only disable one set of buttons for a apex:pageBlock at a time. If ‘both’ is specified for the button location, only the clicked set of buttons on top or bottom will be disabled while processing. I usually select only one location to prevent additional button clicks.
  • Add the immediate=”true” attribute to the Cancel. This bypasses Visualforce validation that would normally fire on the form.

active buttons
disabled buttons







public with sharing class ExamplePageController {

  public ExamplePageController() {
    // do constructor logic
  public PageReference DoSave() {
    // do save logic
    return null;
    public PageReference DoCancel() {
    // do cancel logic
    return null;

7 Replies to “Disable Visualforce Buttons When Processing – apex:actionStatus

    • Even, I am facing the same error. Apex Page message are not coming when I put action status.

    • You will need to rerender the tag that contains apex:pageMessages or the apex:pageMessages tag itself. I have updated the post to show an example.

  1. I have command button that I want disable it while it is processing and after processing I want to redirect it to different page? Can you help me please.

    • In the example, the button returns a null PageReference. This refreshes the page. You could return a PageReference to a new page, and the user would be redirected.

        public PageReference DoCancel() {
          PageReference MyPR = new ApexPages.PageReference('/apex/AnotherPage');
          return MyPR;
  2. The above code is calling my save method twice. This should stop on first custom validation error but won’t. Please help.

Comments are closed.