Skip to content

Instantly share code, notes, and snippets.

@pchittum
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save pchittum/fa8f3097c0c82ad8e4ae to your computer and use it in GitHub Desktop.

Select an option

Save pchittum/fa8f3097c0c82ad8e4ae to your computer and use it in GitHub Desktop.
Component Binding to Page
public class ComponentController {
public Id myId {get;set;}
public Expense__c exp {
get {
if (exp == null) {
exp = [select Id,Name,Amount__c from Expense__c where id =: myId];
}
return exp;
}
set;
}
}
<apex:component controller="ComponentController">
<apex:attribute name="recId" assignTo="{!myId}" type="Id" description="Pass in an Id to get a value"/>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:outputField value="{!exp.Name}"/>
<apex:outputField value="{!exp.Amount__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:component>
<apex:page standardController="Expense__c">
<c:examplecomponent recId="{!Expense__c.Id}"/>
</apex:page>
@pchittum
Copy link
Author

pchittum commented Mar 4, 2015

Invoke ExamplePage by URL as:

https://<salesforceinstance>/apex/ExamplePage?id=<id-value>

Or add as inline visualforce in page layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment