function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nickname7Nickname7 

Custom Visualforce Component cannot resolve managed package's namespace

Hi,

 

I have a pretty simple custom component that is in a managed package and deployed to an organization that has no namespace. In this case, Salesforce seem to be having an issue resolving the correct namespace. Here is the simplest way of reproducing the issue:

 

1, First create a custom page that will be the target of our button that is in our custom component:

 

<apex:page >
  <h1>Target Page</h1>
</apex:page>

 

 

2. Create a custom controller called TestController:

 

global with sharing class TestController
{

    public TestController()
    {

    }
    
    public PageReference goToNextPage()
    {
    
        return Page.test__TestNextPage__c;
    }
    
    static testMethod void runTestCases()
    {
        TestController t = new TestController();
        system.assertEquals(t.goToNextPage().getUrl(), Page.test__TestNextPage__c.getUrl());
    }   
}

 3. Now create a custom component that will use the above controller:

 

<apex:component controller="TestController" allowDML="true" access="global">
 
 <h1>Test componet</h1>
 <apex:form >
     <apex:pageBlock id="testBlock" title="Test Block" rendered="true">
     
         <apex:pageBlockButtons location="top">
            <apex:commandButton action="{!goToNextPage}" rendered="true" value="Go To Next Page" disabled="false" />
         </apex:pageBlockButtons>
     
     </apex:pageBlock>
 </apex:form>
</apex:component>

4. Now package this up as a managed package and deploy it into an ORG that has no namespace defined.

5. In the new ORG, create a new custom visualforce page that will use the packaged test component:

 

 

<apex:page >
  <h1>Test Page</h1>
 
  <test:TestComponent id="testComponent" rendered="true" />
</apex:page>

6. Now when you navigate to the page, and click on the "Go To Next Page" button you get the following error:

 

URL No Longer Exists

If you then add a namespace to the same ORG, the button starts working. Any ideas, suggestions?

 

Thanks!

 

 

 

 

jwetzlerjwetzler

If you have something that doesn't work when your org is not namespaced but suddenly starts working when you give your org a namespace, that's a bug.  Thanks for the thorough repro steps, can you please log a case with support so that this gets escalated to the team properly?

TLFTLF

I have been experiencing similar problems with Visualforce components within a managed package. The problem seems to have started right around the time of the Summer '10 release. I have been working with Salesforce support to try to get a resolution on the problem. In my case, I am passing a custom object type in to my component as a component attribute. The package namespace does not seem to be applied to the custom object type name, so that I get errors like this when I try to package:

 

 

Unsupported type MyType__c for attribute <MyPackage:TicketEmailOrderDetailHTML order>. core.apexpages.el.UnsupportedTypeException: Unsupported type MyType__c for attribute <MyPackage:TicketEmailOrderDetailHTML order>. at core.apexpages.components.cdk.TypeParser.handleUnsupportedType(TypeParser.java:132) at core.apexpages.components.cdk.TypeParser.getType(TypeParser.java:113) at core.apexpages.components.framework.context.ApexViewCompiler.getApexType(ApexViewCompiler.java:384) at core.apexpages.components.cdk.impl.AttributeInfoImpl.getApexType(AttributeInfoImpl.java:73) at core.apexpages.page.udd.ApexComponentObject.saveHook_Validate(ApexComponentObject.java:147) at common.udd.object.

The component and type are both within the same package namespace. The stack trace seems to point to code deep within the Visualforce component parser. It seems that somewhere in the pipeline, the object type is not being namespace qualified. Even if I try to explicitly prefix "MyType__c" with "MyPackage__", the Visualforce compilation process strips out the "MyPackage__" qualifier during the compilation process.

 

TLFTLF

According to Salesforce support, a hotfix was rolled out between 7/8 and 7/9 that appears to have fixed the issues that I was having with packaging of Visualforce components. Nickname1, not sure if this hotfix addressed your original problem, but I suspect it may have.

Nickname7Nickname7

Unfortunately it is still giving us the same error. Thanks for the note anyways.

Sushma_RaoSushma_Rao

We too are facing the similar problem has some one found the solution.

 

We have created a VF component which is a part of the package and now am creating a new vf page in another org and trying to use this component, how should i reference the component.

 

Please help.

TLFTLF

To reference a packaged component, you use the package name in the component tag. For example, if you have a component called "MyComponent" in a package with the namespace "mypackage", you would include the component in your page by inserting the tag <mypackage:MyComponent ... />. I'm not sure I answered your question.

TLFTLF

By the way, if you are going to try to use a packaged component from outside of your package, your component must also be declared as global by setting the "access" attribute to "global" as follows:

 

<apex:component name="MyComponent" access="global" ... >
.
.
.
</apex:component>

 

Sushma_RaoSushma_Rao

Thanks for the reply,

This was very useful.

kreshocskreshocs
This works now.