0

I have a visual force page and a button called that is supposed to take the user to another visual force page.

A problem however is this page is completely blank or just isn't loading it seems.

UDCallout.vfp

   <table width="100%">
        <tr>
            <td width="20%"><apex:commandButton action="{!createQuote}" value="Create Quote" /></td>
        </tr>
    </table>

Apex Controller

public PageReference createQuote()
{
    PageReference pr = new PageReference('/apex/UDQuote');
    pr.setRedirect(true);
    return pr;
}

UDQuote.vfp

<apex:page>
    hello world
</apex:page>
  • can you try instead of PageReference pr = new PageReference('/apex/UDQuote'); the following line: PageReference pr = Page.UDQuote; ? – Oleksandr Berehovskyi Oct 19 '18 at 11:12
2

This should be sufficient and avoids typos in the page name and to ensure that the page is present:

public PageReference createQuote()
{
    return Page.UDQuote;
}

though you would get the error of "Page UDQuote does not exist" if it wasn't.

I'd update the text in the page to be sure something is there in case a blank version of the page is in the org.

PS

In response to the comment question about adding parameters, the expression Page.UDQuote is really a factory method that creates a new PageReference instance so you can pass parameters like this:

public PageReference createQuote()
{
    PageReference pr = Page.UDQuote;
    pr.getParameters().put('myKey', 'myValue');
    return pr;
}
  • Is there a way to also pass a parameter to that page or its own apex controller, for example an Id or list? – Alexander Atkinsoon Oct 19 '18 at 12:19
  • @AlexanderAtkinsoon See the PS. – Keith C Oct 19 '18 at 12:25

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.