3

I have a managed package installed in a subscriber org. The managed package contains a Visualforce Component that I want to use in subscriber org.

My goal is to use a subscriber org VF component within a managed package VF component on a subscriber org page.

e.g. enter image description here

Subscriber org page

<apex:page standardController="myNamespace__myObject__c">

    <myNamespace:myManagedPackageComponent>
        
        <c:mycomponent recordId="{!myNamespace__myObject__c.Id}" />

    </myNamespace:myManagedPackageComponent>
    
</apex:page>

The page saves without error.

When I navigate to this page, i get an error:

Unknown component c:mycomponent

I've tried with access="global" on both mycomponent and it's attributes, but still get this error.

I've confirmed mycomponent works by adding it to the page outside of the myNamspace:myManagedPackageComponent component.

Is there any way to include subscriber org VF components within a managed package VF component?

A similar scenario might be when using Visualstrap on a page, and wanting to include a VF component within the visualstrap component.

4
  • 1
    I do not really understand de scenario. Would you like to use <c:MyComponent> as an "attribute" so it can be rendered inside of the managed component? – Gabriel Serrano Salas Jul 20 '20 at 11:13
  • @GabrielSerranoSalas I've updated the question. It's hard to explain, but I hope this helps – Nick Cook Jul 21 '20 at 1:52
  • I don't think it is possible. As far as I understand what happens is when you try to embed your custom VF component into a managed package one, it treats c: as myNamespace: and tries to find mycomponent inside the myNamespace namespace. You can try to prove my theory by using c:someOtherManagedComponent from myNamespace inside myNamespace:myManagedPackageComponent. – nchursin Jul 21 '20 at 7:28
  • I would suggest you to see the managed package myManagedPackageComponent documentation, and confirm if the component support embedded components within myNamespace:myManagedPackageComponent. The managed VF cmp should used <apex:componentBody /> placed somewhere to be able to do embed other components. – Sam.A. Jul 24 '20 at 16:29
0

I think it would be possible, as long as thhe managed package component is implementing somewhere inside the apex:componentBody/ tag. Here is an example:

<!-- Page: --> 
<apex:page>
    <apex:outputText value="(page) This is before the custom component"/><br/>
    <c:bodyExample>
        <apex:outputText value="(page) This is between the custom component" /> <br/>
    </c:bodyExample>
    <apex:outputText value="(page) This is after the custom component"/><br/>
</apex:page>

<!-- Component: bodyExample -->
<apex:component>
    <apex:outputText value="First custom component output" /> <br/>
    <apex:componentBody />
    <apex:outputText value="Second custom component output" /><br/>
</apex:component>

More details on the below documentation link: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_componentBody.htm

I would say that if the component is not implementing that and of course the package its not of your own (something you can not modify) this is not an achievable goal.

2
  • I'm not sure I understand how this explains how to use a subscriber org VF component within a managed package VF component. Are you able to elaborate? – Nick Cook Jul 22 '20 at 1:25
  • It does not explain it in any special way, since it should not be different. You are doing it as it is suposed to be done I guess. In the example <apex:outputTest> is used inside a custom VF component. Maybe you can try to use <apex:outputTest> inside of the managed VF component to see if that works, but I think that the problem is on the fact that this managed component does not have the required <apex:componentBody/> within although we probably can not check it since it is managed and its code is not visible – Gabriel Serrano Salas Jul 22 '20 at 8:02

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.