Monday, January 27, 2014

What is dynamic binding in salesforce

What is dynamic binding in salesforce

Dynamic Visualforce bindings are a way of writing generic Visualforce pages that display information about records without necessarily knowing which fields to show. In other words, fields on the page are determined at run time, rather than compile time. This allows a developer to design a single page that renders differently for various audiences, based on their permissions or preferences. Dynamic bindings are useful for Visualforce pages included in managed packages since they allow for the presentation of data specific to each subscriber with very little coding.

Example 1:
Access the Account name from Contact.
{!myContact['Account'][fieldname]}

Example 2:
Consider Data type in Apex
public Map<String, List<Account>> accountsMap {get; set;}

Visualforce page:
<apex:variable value="A" var="selectedKey" />
<apex:pageBlockTable value="{!accountsMap[selectedKey]}" var="acc">
   <apex:column value="{!acc.name}"/>
   <apex:column value="{!acc.BillingStreet}"/>
   <apex:column value="{!acc.BillingCity}"/>
   <apex:column value="{!acc.BillingPostalCode}"/>
</apex:pageBlockTable>

Read more about Visualforce dynamic binding on bob buzzard’s blog

<apex:variable var="count" value="{!1}"/>
within loop
<apex:variable var="count" value="{!count + 1}"/>


No comments:

Post a Comment