1

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); 
2

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

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

with the controller

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

yields

Visualforce page screenshot

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

0

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.