This is my VF page "TestPage":
<apex:page standardController="Account">
<c:TestComponent recordId="{!account}" />
</apex:page>
Visual Force component "Test Component":
<apex:component controller="Taccount">
<apex:attribute name="recordId" description="Record Id to show field history for." type="sobject" assignTo="{!record}" required="true"/>
<apex:relatedList list="Opportunities"/>
<apex:relatedList list="record.Opportunities"/>
</apex:component>
Problem is that <apex:relatedList list="Opportunities"/> or <apex:relatedList list="record.Opportunities"/>
is not showed in the main page"TestPage".
Do you know how can i show, in the main page, a related list added in a component?
Thanks in advance for any advice.
Best Answer
You can do this by setting the
subject
attribute ofapex:relatedList
.For example:
The component can be written to accept the account record as an attribute passed into it.
The VF Page can pass the account record.
The result will be that the Opportunities for the Account specified by the id parameter will be displayed within the component.