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
kzmpkzmp 

Dinamically display components

Hi,

We have designed 1 component which displays some basic informatin to the user let say emails.

We have a VF page on which we would like to show as many components of those as the number of emails that we have.

 

The page controller knows the number of emails and they are kept in a collection.

For example: String [] emails;

if we have two emails we want our VF page to display two of our custom VF components and we want to pass to them emails[0] and emails[1] to display.

 

Any help with this will be appreciated.

 

Kos

 

Best Answer chosen by Admin (Salesforce Developers) 
Jon Mountjoy_Jon Mountjoy_

Can't you embed your component within another one that does iteration?  

For example:

 

<apex:dataList value="{!accounts}" var="account" id="theList">
  <c:myComponent value="{!account.name}"/>
</apex:dataList>

 

 

 

Alternatively:

 

It sounds like you have a component that takes one argument, say the email.

 

Change the component to take a list of arguments, and let *it* to do the iteration. 

 

All Answers

Jon Mountjoy_Jon Mountjoy_

Can't you embed your component within another one that does iteration?  

For example:

 

<apex:dataList value="{!accounts}" var="account" id="theList">
  <c:myComponent value="{!account.name}"/>
</apex:dataList>

 

 

 

Alternatively:

 

It sounds like you have a component that takes one argument, say the email.

 

Change the component to take a list of arguments, and let *it* to do the iteration. 

 

This was selected as the best answer
kzmpkzmp

Thank you very much for the answer.

It seems that his is exactly what we want.

 

Regards,

Kos