Related to this question How to keep components out of the Visualforce view state when they are not needed?, I have many apex:dynamicComponents in my page that I want to put slightly different content into.

It looks like I will need a controller method per variation e.g.:

public ApexPages.Component getMedical_top_extension() {
    return extension.rootComponent(Section.Medical, Position.top);

referenced in the page as e.g.:

<apex:dynamicComponent componentValue="{! Medical_top_extension }"/>

Or is there a way to pass a parameter to a single controller method instead? I am assuming not as e.g. apex:param makes no mention of apex:dynamicComponent.

1 Answer 1


All of the documented methods for setting an attribute dynamically are not supported. I tried the following methods:

demox = new Component.q239762(value=5);

Field does not exist: value on Component.q239762

demox.value = 5;

Variable does not exist: value

demox.expressions.value = 5;

Type is not visible: ApexPages.expressions

I also tried a few other variants to try and hack my way through, like trying to find a method setAttribute, etc, all of which resulted in other compilation errors.

As such, I have to conclude that setting attributes is only supported for standard components, and primarily meant to deal with rendering complex layouts.

Any work on Visualforce is mostly maintenance and security at this point, so there's little to no hope that they'd ever add a feature like this. Still, it wouldn't hurt to check the IdeaExchange.

  • Thanks for taking such a detailed look. I now have 48 methods in my controller to handle the permutations generated via a spreadsheet formula. OK for this case where the permutations are known, but not for more general cases. So disappointing that there isn't a mechanism. Such a niche thing that I'm 99% sure it won't get addressed so I'll be skipping the IdeaExchange. Thanks again.
    – Keith C
    Commented Nov 19, 2018 at 10:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .