Releases often bring big improvements to the platform, like being able to update your data schema visually, but they’re also about improvements in general to the technology (like making Apex REST easier to use).  With every release there’s a variety of updates which are important even if they’re not the most interesting demo on the planet.  Sometimes these small updates are the type which allows a developer to remove existing code in order get something done.

For instance, dynamic references in Visualforce go generally available in Spring ’12, so (for instance)  you’ll be able to dynamically update which field an inputField would see based on an extension.  So if you wanted to show to edit a specific contact’s phone number (phone, mobile, assistant) based on an incoming area code, you could have this in Visualforce:

<apex:inputField value="{!Contact[mainContactField]}"/>

And this in Apex:

public String mainContactField {get; set;}
	
	public TestController(ApexPages.StandardController std) {
		Contact c = (Contact)std.getRecord();
		mainContactField = 'Phone';
		
		List<Contact> cWithRecords = [SELECT Id, Phone, MobilePhone, AssistantPhone, OtherPhone from Contact where ID = :c.Id];
		if(cWithRecords.size() > 0) {
			if(ApexPages.currentPage().getParameters().get('area') != null) {
				if(cWithRecords[0].Phone.replaceAll('[^0-9]+','').startsWith(ApexPages.currentPage().getParameters().get('area'))) { mainContactField = 'Phone'; }
				if(cWithRecords[0].MobilePhone != null && cWithRecords[0].MobilePhone.replaceAll('[^0-9]+','').startsWith(ApexPages.currentPage().getParameters().get('area'))) { mainContactField = 'MobilePhone'; }
				if(cWithRecords[0].AssistantPhone != null && cWithRecords[0].AssistantPhone.replaceAll('[^0-9]+','').startsWith(ApexPages.currentPage().getParameters().get('area'))) { mainContactField = 'AssistantPhone'; }
				if(cWithRecords[0].OtherPhone != null && cWithRecords[0].OtherPhone.replaceAll('[^0-9]+','').startsWith(ApexPages.currentPage().getParameters().get('area'))) { mainContactField = 'OtherPhone'; }
			}
		}
	}

Or the example we have in the docs show changing out a logo based on an Apex variable controlling which resource is being used.  This can remove some of the methods developers use for switching out aspects of the UI without getting into anything which should terribly stomp all over the MVC model.

As many of you know, one of my personal favorite tools on the platform is JavaScript Remoting, which in Spring ’12 will be getting a performance shot in the arm via data compression.  There’s nothing to enable or change in your code – you should just see faster data transfers.  Similarly, we’re also giving PDF generation a shot in the arm – pages with the renderAs attribute set to PDF should result in smaller (and hence faster to download) pages with Spring ’12.  This comes at a (very) slight cost, however – PDF pages can’t exceed 60MB in size and the total number of images being used can’t exceed 30MB.  I’m thinking that if you have a PDF that large – you might want to split it up anyway (and performance is probably no longer a concern).

Power users of scheduled Apex will be able run 25 concurrent classes as opposed to the previous 10 - a feature which came from the developers on the IdeaExchange.  You’ll also now be able to add triggers to the ContentDocument object, which can be handy if you are trying do things like add event based logic based on recently published documents in Chatter.

So that is some of the goodness wrapped up in Spring ’12.  As usual, leave comments below or catch me on twitter @joshbirk – we’ve got some more Spring ’12 highlights left to go – including unit testing and something which rhymes with “beaming”.

 

tagged , , Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • http://twitter.com/krishnamoorthin Krishnamoorthi

    I need a full source code of above functionality.

  • http://twitter.com/joshbirk Josh Birk

    No problem – I’ve put the complete example into a gist here:
    https://gist.github.com/1838114