Last active
August 29, 2015 14:16
-
-
Save pchittum/fa8f3097c0c82ad8e4ae to your computer and use it in GitHub Desktop.
Component Binding to Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <apex:page standardController="Expense__c"> | |
| <c:examplecomponent recId="{!Expense__c.Id}"/> | |
| </apex:page> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Invoke
ExamplePageby URL as:Or add as inline visualforce in page layout.