The below codes work fine in a brand new VF page as shown below:
<apex:page standardController="Employee__c" >
<c:GenericHistoryComponent my_Object="{!Employee__c}" record_Limit="50"></c:GenericHistoryComponent>
</apex:page>
But my question is, how would you make it work to an existing VF page?
Getting this error:
Error: Unknown property
<apex:page standardController="Visitor__c">
.....
<c:GenericHistoryComponent my_Object="{!Employee__c}" record_Limit="50"> </c:GenericHistoryComponent>
</apex:page>
My component looks like this:
<apex:component controller="GenericHistoryComponentController">
<!-- Attribute Definition -->
<apex:attribute name="myObject" description="Object we wish to view the history of" type="SObject" required="true" assignTo="{!myObject}" />
<apex:attribute name="recordLimit" description="Number of lines of history to display" type="Integer" required="false" assignTo="{!recordLimit}" />
<apex:form >
<!-- Object History Related List -->
<apex:pageBlock id="historyTable" title="{!objectLabel} History">
<apex:pageBlockTable value="{!ObjectHistory}" var="History" >
<apex:column headerValue="Date" value="{!History.thedate}"/>
<apex:column headerValue="User">
<apex:outputLink value="/{!History.userId}"> {!History.who} </apex:outputLink>
</apex:column>
<apex:column headerValue="Action"><apex:outputText escape="false" value="{!History.action}"/></apex:column>
</apex:pageBlockTable>
<apex:outputPanel rendered="{!tableSize > rowCount}">
<div class="pShowMore">
<apex:commandLink value="Show more »" rerender="historyTable" action="{!refreshObjectHistory}">
</apex:commandLink>
|
<a href="/_ui/common/history/ui/EntityHistoryFilterPage?id={!myObjectId}">Go to list »</a>
</div>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:component>
Best Answer
Assuming the component and its
GenericHistoryComponentController
will work with any type of object, you just need to supply an SObject reference. For a standard controller. That reference is given the same name as the type that is specified by thestandardController
attribute.So for this to work with your existing page it's:
PS
On the subject of displaying the history of a different object, if there is a field reference to one instance (i.e. a parent) you could do this:
but if not you will have to write a controller extension that provides a property to the single instance.