Adding Visualforce to a Salesforce AppExchange App
You can include Visualforce pages, components, or custom controllers in an app that you are creating for AppExchange.
Unlike Apex classes, the content of a Visualforce page in a managed package is not hidden when the package is installed. However, custom controllers, controller extensions, and custom components are hidden. In addition, custom components can be restricted with the access attribute to run only in your namespace.
Salesforce recommends that you only use managed packages to distribute any Visualforce or Apex components. This recommendation is because managed packages receive a unique namespace that is automatically prepended to the names of your pages, components, classes, methods, variables, and so on. This namespace prefix helps prevent duplicate names in the installer’s organization.
Consider the following caveats when you create a package using a Visualforce page:
-
If the
accessattribute on a component that is included in a managed package is set toglobal, be aware of the following restrictions:- The
accessattribute on the component cannot be changed topublic. - All required child
<apex:attribute>components (those that have the required attribute set to true) must have theaccessattribute set to global. - If the
defaultattribute is set on a required child<apex:attribute>, it cannot be removed or changed. - You cannot add new required child
<apex:attribute>components. - If the
accessattribute on a child<apex:attribute>component is set toglobal, it cannot be changed topublic. - If the
accessattribute on a child<apex:attribute>component is set toglobal, thetypeattribute cannot be changed.
- The
-
When a package with a non-global component is installed, users that view the component in Setup see “Component is not global” instead of the content of the component. In addition, the component is not included in the component reference.
-
If advanced currency management is enabled for an organization that is installing a package, Visualforce pages that use
<apex:inputField>and<apex:outputField>cannot be installed. -
Any Apex that is included as part of an AppExchange app must have at least 75% cumulative test coverage. When you upload your package to AppExchange, all tests are run to ensure that they run without errors. The tests are also run when the package is installed.
-
Beginning with version 16.0, if you have a managed
globalApex class used as a Visualforce controller, it is also required that the access level be set toglobalfor the following methods and properties for subscribers to use them:- Constructors for custom controllers
- Getter and setter methods, including those for input and output components
- Get and set attributes on properties
If a custom label has translations, include the translations in a package by explicitly packaging the desired languages.
To prevent malicious code in a package from affecting your data, when a package containing Visualforce pages is installed into an organization, the pages are served from the vf.force.com, domain instead of the salesforce.com domain.
See Also