Stat Tracker

Friday, March 18, 2011

Similarities between JSF 2.0 and Force.com

I don't know if many people know this, but under the hood Force.com runs on JSF. Salesforce doesn't publish this information anywhere that I know of (if you know please share!). As a developer, if you are familiar with JSF than when you start working with Force.com you should be able to make the transition fairly smoothly. This hopefully should remove the sticker shock from anyone who is looking at implement Salesforce.com and thinks "Visualforce and Apex? I don't have people who can support that?". Well, if you have Java developers, there's a good chance they can use their existing skill sets to help support your Force.com implementation.

The two major components of the Force.com platform are Visualforce and Apex. The first part is Visualforce. You can think of Visualforce as a tag library which wraps around JSF tags. Instead of having a tag like <h:datatable> in JSF the Visualforce equivalent is <apex:datatable>. You'll find many of the JSF components (Templates, Compositions, PanelGrid, OutputText, InputText, ETC) have almost identical wrappers in Visualforce with the major difference being the taglib using the <apex:> name space.

The second major component is Apex. Apex is essentially a wrapper around Java. In JSF you have backing beans for your JSF pages. In Force.com, your backing bean is an Apex Controller. The Java Bean naming convention applies just like it does in JSF. So if you have a property called "accountName" with a getter of "getAccountName()" in your backing bean, you would acces it in JSF by #{beanName.accountName}. Its the same way in Force.com except when you bind to your Apex Controller Class attribute to the Visualforce page you use {!apexClass.accountName}.

There are many more similarities to JSF. For example, in your Apex Classes the ApexPages classes are similar to the FacesContext classes. There are lots of other examples but for the scope of this blog just wanted to point out that basic similarity between JSF and Force.com for folks who didn't know they had a relationship.