0

I have created a custom Visualforce page and controller. I would like to know how to visualize the page I created in the context of Salesforce environment. I would like to know how to open the page: 1. Is it possible to create url address and somehow to use it in order to open the page? 2. Is it possible to invoke the page by using apex source code. I looked in other sites and I found that it can be achieved but I did no find a way to make it work. 3. Is there some other approach or way to open the custom page?

1 Answer 1

1
  1. Manually editing your browser's URL to e.g. https://na15.salesforce.com/apex/YourPageName?id=003i000000QT3nr will display your page; you can append parameters such as the "id" one.
  2. In your Apex code, the symbol Page.YourPageName creates a new PageReference each time you reference it and that can be returned from a controller action method (example shown in the PageReference link) to select the next page displayed.
  3. If you have made your page an extension of a standard controller, you can hook your page in in place of the standard actions (via the object's "Buttons, Links, and Actions" section) like New or View or Edit. This is a good technique to use for custom objects where you always want your Visualforce page to be used and you undserstand all use cases; it is a bad technique to use for standard objects because the override applies to all users irrespective of their profile so you are impacting every user and every app.

PS

In response to the comment, this should do it (and has the benefit of being compile-time checked):

public PageReference ErrorMessage7() {
    return Page.ErrorMessagePage;
}

or if you had some string reason to want to use a string use this relative URL (which is portable to different orgs):

public PageReference ErrorMessage7() {
    return new PageReference('/apex/ErrorMessagePage');
}

If you want to add parameters (i.e. values appended in the ? query string):

public PageReference ErrorMessage7() {
    PageReference pr = Page.ErrorMessagePage;
    pr.getParameters().put('id', ...);
    pr.getParameters().put('xyz', ...);
    return pr;
}
1

You must log in to answer this question.

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