Adding Visualforce to a Force.com AppExchange App. salesforce Visualforce Developer Guide
Publicité
Publicité
CHAPTER 20 Adding Visualforce to a Force.com 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.
The following caveats should be taken into consideration when creating a package using a Visualforce page:
•
If the access
attribute on a component that is included in a managed package is set to global
, be aware of the following restrictions:
–
The access
attribute on the component cannot be changed to public
.
–
All required child
<apex:attribute >
components (those that have the required attribute set to true) must have the access
attribute set to global.
–
If the default
attribute 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 access
attribute on a child
<apex:attribute >
component is set to global
, it cannot be changed to public
.
–
If the access
attribute on a child
<apex:attribute >
component is set to global
, the type
attribute cannot be changed.
•
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 Force.com 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 global
Apex class used as a Visualforce controller, it is also required that the access level be set to global
for 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
Tip:
If a custom label has translations, include the translations in a package by explicitly packaging the desired languages.
297
Adding Visualforce to a Force.com AppExchange App Managing Package Version Settings for Visualforce Pages and Components
When a package containing Visualforce pages is installed into an organization, the pages are served from the visual.force.com
domain instead of the
Salesforce
domain. This is to prevent malicious code in a package from affecting your data.
SEE ALSO:
Testing Custom Controllers and Controller Extensions
Managing Package Version Settings for Visualforce Pages and
Components
If Visualforce markup references installed managed packages, the version settings for each managed package referenced by the Visualforce markup are saved to aid backwards-compatibility. This ensures that as the components in managed packages evolve in subsequent package versions, a page is still bound to versions with specific, known behavior.
A package version is a number that identifies the set of components uploaded in a package. The version number has the format
majorNumber.minorNumber.patchNumber
(for example, 2.1.3). The major and minor numbers increase to a chosen value during every major release. The
patchNumber
is generated and updated only for a patch release. Publishers can use package versions to evolve the components in their managed packages gracefully by releasing subsequent package versions without breaking existing customer integrations using the package.
Note: Package components and Visualforce custom component are distinct concepts. A package is comprised of many elements, such as custom objects, Apex classes and triggers, and custom pages and components.
To configure the package version settings for a Visualforce page or custom component:
1. Edit a Visualforce page or component and click Version Settings.
2. Select a
Version
for each managed package referenced by the Visualforce page or component. This version of the managed package will continue to be used by the page or component if later versions of the managed package are installed, unless you manually update the version setting. To add an installed managed package to the settings list, select a package from the list of available packages. The list is only displayed if you have an installed managed package that isn’t already associated with the page or component.
3. Click Save.
Note the following when working with package version settings:
•
If you save a Visualforce page or custom component that references a managed package without specifying a version of the managed package, the page or component is associated with the latest installed version of the managed package by default.
•
You can’t Remove a Visualforce page or component’s version setting for a managed package if the package is referenced by the page or component. Use Show Dependencies to find where the managed package is referenced.
SEE ALSO:
Managing Version Settings for Custom Components
298
Télécharger
Publicité