+ Start a Discussion
NaishadhNaishadh 

Dynamically Add Component in Page

Hi,

 

I have developed different component and I want to add it in visual force pages at runtime. Same like one can add component in Google and myyahoo page.

 

I don't find any way of doing this. Please help!

 

 

David VPDavid VP

Not out of the box.

You might want to create your own framework in VF / Apex to manage this (Don't know if it can be done but at the very least it will be quite a bit of work)

NaishadhNaishadh

Hi David,

 

Thanks for reply.  

 

I have already developed all the component and master page in which I am able to do drag and drop. The only issue is I don't know how to add component at runtime.

 

i.e. suppose i have 3 component component1,component2 and component3.

 

I want to add 2 of this in the page at runtime.

 

If I try to add it using apex:repeat it simply display as text in place of loading the component.

 

Any help! 

David VPDavid VP

I do not think you can do this at runtime.

 

What you could do is something like :

Create a page (or another component) that has ALL your components on it, these components have a 'rendered' attribute that's pointing to a set of booleans in your controller (all defaulted to 'false').


Include the page/component where you want the components to appear dynamically and make sure that via your framework you flip the correct boolean(s) to true. That way your components will magically appear or dissapear in your drop target ...

 

Just an idea.

nathanael.mnathanael.m

I've attempted such an implementation and regularly run into the viewstate limit. For some reason even though the rendered attribute is set to false for the components that are not rendered, they are still stored in the viewstate.

 

It would definitely work as a temporary fix but we need dynamic component binding:

 

http://ideas.salesforce.com/article/show/10097513/Custom_Component_Binding