Sunday, 30 October 2011

Dynamic Visualforce bindings

Dynamic Visualforce binding is useful to write generic Visualforce pages that display information about records without knowing which fields to show. In other words, fields on the page are determined at runtime, rather than compile time.

To create a new field set:


Navigate to the field set list of the appropriate object:
    • For standard objects, click Your Name | Setup | Customize, select the appropriate object from the Customize menu, and click Field Sets.
    • For custom objects, click Your Name | Setup | Create | Objects, and select one of the custom objects in the list. Then click New above the field sets related list.


eg.
<apex:page standardController="Contact">

    <apex:form >
        <apex:repeat value="{!$ObjectType.Contact.FieldSets.Demo_Field_Set}" var="f">
            <apex:InputText value="{!Contact[f]}" /><br/>
        </apex:repeat>
    </apex:form>
</apex:page>

No comments:

Post a Comment