1

I want to redirect to an intermediate visualforce page, whose functionality is to store the parameters passed in URL to a salesforce record(custom object). But the complex part here is, I want to achieve this functionality without actually opening that page up. So, ultimately the user should be redirected to the third visualforce page without actually opening up the intermediate page, though the processing should be done. How can I achieve this functionality?

1
  • Please rephrase your question it's a bit confusing. Maybe a small flow like page1(details)>page2(details)>page3(details) may help
    – Jarvis
    Commented Feb 3, 2016 at 19:28

2 Answers 2

3

You can use the action attribute of apex:page to accomplish what you want. From the documentation:

This method will be called before the page is rendered and allows you to optionally redirect the user to another page.

So with this in Page2:

<apex:page action="{!init}" ...>

and this method in the Page2 controller:

public PageReference init() {
    // Do the processing you need here
    return Page.Page3;
}

the Page2 controller can do some processing without ever rendering any output.

1

You could send the GET request to the intermediate Visualforce page from Apex, so the clients browser doesn't need to perform the request.

One way to do this is to build up a PageReference with the required query string parameters and then call getContent(). E.g.:

PageReference intermediatePageRef = Page.intermediatePage;
intermediatePageRef.getParameters().put('id', myID);
intermediatePageRef.getContent();

Note that this will be treated as an API callout in v34.0 and onwards.


Another option would be to build the raw HttpRequest and send that off. Probably the only advantage of this approach is that you don't need to bring the full response body back.


Depending on what the intermediate Visualforce page returns, you might also be able to use apex:include on the final Visualforce page to cause it to load.

You must log in to answer this question.

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