I have a managed base package that contains Visualforce components and pages that I would like to reuse in its extension package.

I don't want to make them global as this would allow customers to reuse my components in their own package. This makes them hard to change, remove and the like.

Is there any alternative to build "friend" extension packages that can use functionality of a "friend" base package?


The long and short answer is: no

There is no platform support for multiple packages from the same vendor sharing code without using the 'global' access modifier. This applies to VF Components, Apex Classes and Lightning Components.

The only alternative to using a global VF Component is to create a global Apex class that exposes Dynamic Visualforce Component -- and expose that method via your extension package's VF Page controller. Depending on your use case, this is usually a worse and more convoluted scheme than just creating a global VF component -- the only advantage is that it allows you to instantiate the VF Component at runtime rather than have a statically compiled in reference which may be handy depending on the use case.

Lastly, if you go the global VF Component route, you probably want to opt for a single apex:attribute for your VF component that is of type Map so that you can add attributes (or 'deprecate' old ones) in the future without needing to change the signature of the VF Component in your base package

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.