We have used this code previously for showing error, but now we want to show the error on top and on the bottom of the page:

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.CustomLabel); 

You're free to include multiple <apex:pageMessages /> components, positioned wherever on the page you want.

    <apex:pageMessages />
    <apex:pageMessages />
    <apex:commandButton action="{! addErrors }" title="Test" value="Test"/>

with the controller

public PageReference addErrors() {
    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Test'));
    return null;


Visualforce page screenshot

Simply add more <apex:pageMessages /> components wherever you need to display your current page's errors.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.