You need to sign in to do that
Don't have an account?
jumping to specific section of visual force page
I have a visual force page that basically lists a bunch of elements, allows you to select an element, and then shows you certain details of the element you selected below the list. The page has the structure (summarizing) :
<apex:page> <apex:form> <apex:pageblock> <apex:pageBlockSection> <apex:pageBlockTable> <!-- this is my list --> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockSection > <!-- this is my details, rendered only if something selected --> </apex:pageBlockSection> </apex:pageBlock> <apex:form> </apex:page>
The rendering/visibility aspects all work fine (ie when I click an item in my list, it calls an apex function that ensures the details section is visible, etc). But I always return to the top of the page when I'd like to return to the bottom or details section of the page.
One way I can get around this is to reconstruct a URL/PageReference and load it up with the parameters required to get me back to this state, ie something like:
PageReference pr = ApexPage.currentPage(); pr.setAnchor('mainPage:mainForm:mainBlock:detailsSection'); pr.setRedirect(false); pr.getParameters().put('detail', detailId); pr.getParameters().put('id',mainId); return pr;
That works, but it basically reloads the entire page in the browser (ie the browser sees the new URL). I thought that if I could just return an anchor marker from the function that it might jump to that page section without reloading the page, ie without adding the parameters:
PageReference pr = new PageReference(''); pr.setAnchor('mainPage:mainForm:mainBlock:detailsSection'); pr.setRedirect(false); return pr;
It says its returning '#mainPage:mainForm:mainBlock:detailsSection' as the return value (from a system debug command just before the return), but it also ends up either hanging the browser or reloading the entire page (which doesn't work unless I add more parameters to get me back to the correct state).
I was wondering if there's an easier way to move around in the page (so I can go to a specific anchor/section of the page after performing a specific apex function to pull the details of the record from the database) that doesn't require the browser reloading the entire page. Any suggestions?