Search code examples
apex-codevisualforce

Can we dynamically set the value of "list" attribute of <apex:relatedList> component?


I am trying to design a generalized detail page for an object.

In the controller class I find the list of all child relations of that object.

I then want to create for each child relations found and for accomplishing this I will have to dynamically set the value of list attribute within it.

For example :

<apex:relatedList subject={!ObjName} list="{!relatedListName}" />

But the problem here is that list attribute only accepts String literal, so can't implement it. Please suggest a way for this requirement to be accomplished.


Solution

  • I would suggest trying apex:dataTable or apex:repeat to build your own list display. You will likely need a wrapper class to handle passing attributes and values from the sObject to the page.