1

I am setting an error paremeter then redirecting to another VF page like this:

        PageReference backtosite = new PageReference('/apex/Fs_ViewSiteAddress?id='+parentId);
        System.debug('redirect url to site record: '+backtosite.getUrl());
        backtosite.getParameters().put('ERROR','You are not allowed to do that');
        //backtosite.setRedirect(true);
        return backtosite;

.. then I show the message like this:

<apex:pageMessage strength="3" severity="error" rendered="{! NOT(ISBLANK( $CurrentPage.parameters.ERROR ))}">You are not allowed to do that with this profile</apex:pageMessage>

I want my error message to be right above the related list it is genereated by, but after the re direct the focus is at the top of the page. How can I focus on the page message with the error, so the user doesn't have to scroll all the way down ?

1 Answer 1

2

You can use HTML fragment identifier [0] and redirect to it so browser can scroll to that area and make it visible.

To use it, generate a anchor tag with some value and specify that value in the redirect url as '/apex/Fs_ViewSiteAddress?id='+parentId +'#error-place

[0] https://en.wikipedia.org/wiki/Fragment_identifier

1
  • thanks I'll try it out
    – MadMax
    Apr 8, 2019 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .