Thursday, May 17, 2012 Summer'12 Features

There are some Awesome features coming up in Summer'12 release. This is one release for which every developer is waiting. Some of the interesting features listed below. I can't wait to lay my hands on these and test them....Phew!

Apex Describe Support for Field Sets
Visualforce dynamic bindings have supported field sets for some time. In Summer ’12, Apex provides describe support
for field sets, which makes it possible to dynamically generate the SOQL necessary to load all fields in a field set. This
makes field sets easier to use in Visualforce pages that use custom controllers.
This sample uses Schema.FieldSet and Schema.FieldSetMember methods to dynamically get all the fields in the
Dimensions field set for the Merchandise custom object. The list of fields is then used to construct a SOQL query that
ensures those fields are available for display. The Visualforce page uses this class as its controller.

Single View State—Generally Available
The Single View State optimization introduced as a pilot feature in Spring ’12 is generally available in Summer ’12.
Single View State will be activated on existing organizations within 24 hours of deployment of Summer ’12 on your
Salesforce instance.

JavaScript Remoting Enhancements
We’ve enhanced JavaScript remoting in several ways.
To make it easier to work with namespaces, especially for pages that make remoting calls to methods provided in packages,
you can use the $RemoteAction global to automatically resolve the correct namespace, if any, for your remote action.
To use this facility, you must explicitly invoke JavaScript remoting. The pattern for doing this is:

There are lot of other features like

JSON Parser
New Types 
Sorting Support for Non-Primitive Data Types in Lists
Knowledge Management Publishing Service Class
Describe Support for Field Sets
New Interfaces and Methods for Running Apex on Package Install/Upgrade and Uninstall
Allow Reparenting Option in Master-Detail Relationship Definitions
New Lookup Relationship Options etc..

You can get the release notes from here Salesforce Summer'12 Release Notes

Wednesday, May 16, 2012

Dynamic Visualforce Components Explained

Some or the other time you might have faced a challenge of dynamically generating input fields. Most of the time we sticked to dynamic HTML and embed that in our VF page to fulfil our needs.

But now, Salesforce has introduced the new Dynamic visualforce components which means you no longer will be dependent on dynamic HTML for most of your needs.

Here is a sample which shows you how to generate a dynamic input form for Account object.

<apex:page standardController="Account" extensions="DynamicInputForm">
<!-- Create section header dynamically -->
<apex:dynamicComponent componentValue="{!SH}"/>
<apex:form >
<!-- Create dynamic input form for account object -->
<apex:dynamicComponent componentValue="{!ActForm}"/>

public with sharing class DynamicInputForm
    public DynamicInputForm(Apexpages.standardController ctlr)
        //constructor code goes here

    //Create a page block dynamically
    public Component.Apex.PageBlock getActForm()
        Component.Apex.PageBlock pb = new Component.Apex.PageBlock();
        //creating an input field dynamically
        Component.Apex.InputField name = new Component.Apex.InputField();
        name.expressions.value = '{!Account.Name}'; = 'name';
        Component.Apex.OutputLabel label = new Component.Apex.OutputLabel();
        label.value = 'Name';
        label.for = 'name';
        //Use the above block to create other input fields
        Component.Apex.CommandButton save = new Component.Apex.CommandButton();
        save.value = 'Save';
        save.expressions.action = '{!Save}';

        return pb;

    //create section header dynamically
    public Component.Apex.SectionHeader getSH()
        Component.Apex.SectionHeader sh = new Component.Apex.SectionHeader();
        sh.title = 'Create Account';
        return sh;
Updated Visualforce developer guide covers this topic.