I'm trying to use the method @DanielBlackhall gave in this question: Loading a custom component into a Visualforce page dynamically

But unfortunately, this doesn't work anymore:

Type t = Type.forName('Component.c.MyCustomComponent');

always returns null.

  • 3
    I'm guessing the question is, how do you get it to work? – Jesse Altman Feb 12 '13 at 16:58
  • @JesseAltman I think the question is how do you do Load a custom component into a Visualforce page dynamically now that the type.forname method doesn't work. – Greg Grinberg Feb 12 '13 at 17:19

Unfortunately the Type.forName method has limitations and can't be used with Visualforce Components :-( I raised this exact Case to Salesforce and they advised me the same and that it was "out of scope".

Daniel Blackhall very kindly tried his original code again and confirmed we now can't get anything other than null. It can only invoke Primitives, sObjects, Collections and Apex types per the docs.

(You can almost get there with a big hammer like this, but it's not truly dynamic.)

| improve this answer | |
  • Yeah, I saw that on another forum I think. The thing is... I thought I actually had it working last week. Also, apparently, someone else did too. Just making sure I haven't missed anything stupid. – dnakov Feb 12 '13 at 17:01
  • 1
    What is the case number? I have had good luck getting things fixed when they are raised by multiple partners. – Greg Grinberg Feb 12 '13 at 17:04
  • @grigriforce 08493365 - I'll send you a slab of chocolate if you can convince them! – bigassforce Feb 12 '13 at 17:06
  • 1
    @user31 I will definitely give it my best shot. Very annoying as I don't see an alternate method of doing this if type.forname doesn't work. – Greg Grinberg Feb 12 '13 at 17:20
  • Beer too if they'll make ApexPages.Component a supported @RemoteAction return type as well ;-) – bigassforce Feb 12 '13 at 17:25

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.