function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Rerender a command button on Save

I need to Rerender a command button on my VF page on saving the page.


Right now, I have 3 buttons on my VF page, Save, Test, Cancel.

I want that when the user opens this VF page, on button click in contact object, on this Vf page, initially the user should only see the Save & Cancel buttons. Once the user clicks on the Save button, then the Test button should appear.

Any thoughts how this can be done? Can somebody share code snippet?


The save and cancel buttons have the standard salesforce save & cancel function.


Strictly speaking you don't need to rerender the buttons, you can simply conditionally render then when the page is created or refreshed.  You'll need an extension controller for this with its own save method and a boolean property per button.  Then in the page you'd use this boolean property to decide whether to render the button or not.


When the controller is created, the save and cancel properties are set to true and thus those buttons are displayed, while the test boolean property is set ot false.  Then when the user clicks save, your extension controller save method executes the save and sets the test boolean property to true.  Then when the page is redrawn, the correct buttons are shown.