Contents[Hide]

Visualforce Buttons

Back button

Simple example of Back (Cancel) button:

Visualforce:

<apex:commandButton value="Back" action="{!customBack}" immediate="TRUE"/>

immediate (boolean) - allows to skip all validations. It can accelerate also AJAX reRender. Not advised ehen doing Save.

Controller:

    public PageReference customBack() {
        // PageReference pr = new PageReference('partialURL'); // any URL
        // PageReference pr = Page.MyCustomVisualforcePage; // Existing VS page
        pr.getParameters().put('paramName','paramValue'); // if parameters needed
        pr.setRedirect(true);
        return pr;
    }

Component references:
PageReference in documentation
.
CommandButton in documentation

Update record with Save button displaying text indicator.

After pressing save button page is not reloaded, data from from are saved. During saving status message is displayed.

Button:

<apex:commandButton value="Save" action="{!orderSave}" reRender="Order" status="saveStatus" / >

TIP: You can rerender two sections by giving their's ids separated by colon like:

reRender="firstSection,secondSection"

Action status message:

<apex:actionStatus startText="Saving..." id="saveStatus" />

Controller:

public PageReference orderSave() {
        update OrderObj; // Update object with data from form
        return null;
}

Component references:
CommandButton
ActionStatus

Delete link with confirmation popup

 

a

   
© Paweł Woźniak