Monday, 27 September 2010

S-Controls

As I mentioned in my previous entry, Visualforce is the new standard technology that allows you to create custom user interfaces for your force.com applications. I would love to be able to begin teaching you how to build your own applications using Visualforce, but before doing so it is imperative that we re-examine S-controls.

Since S-Controls have been denigrated we can only edit existing ones and install the ones that subsist in legacy managed packages.  However this remnant of older Salesforce programming is still necessary knowledge for the aspiring developer.

S-Controls allow the developer to create custom content. This is hosted by the SFDC system but is actually executed by specific end client applications. It is common knowledge that these S-Controls will usually have a mix of HTML and JavaScript. You can use the Salesforce AJAX Toolkit to update the SFDC data that is JavaScript. The HTML controls and displays the data.

The following is a sample S-Control code using the AJAX Toolkit. It will display a “SF Giants Rule” greeting for the end user:

<html>
<head>
  <script type="text/javascript" src="/js/functions.js"></script>
  <script src="/soap/ajax/8.0/connection.js"></script>
  <script>
    function setupPage() {
      // Use the API connection, named sforce by default, to get
      // the full name of the active user
      var user = sforce.connection.getUserInfo().userFullName;
      // Display "Hello World" plus the full user name by replacing
      // the div defined below
      document.getElementById('userNameArea').innerHTML =
      'SF Giants Rule, '+user;
    }
  </script>
</head>

<body onload=setupPage()>
  <div id=userNameArea>
  </div>
</body>
</html>

Once this new S-Control is created with this code, you can add it to the page layout of an existing object or connect it to its own custom tab. After either one these are loaded, you will see the text “SF Giants Rule” with the user name. This text will be displayed in the S-Control area that they developer has defined.

I am well aware that this very simple description on the use of S-Controls, but it will give you insight on why many developers prefer Visualforce (especially myself) in the next post. 

Thursday, 23 September 2010

What is Visualforce?

The purpose of this introductory blog is to give you a brief introduction on Visualforce. Visualforce is basically a component based framework to build custom pages. This framework uses tags to build components that make up a page. There are about 70 components which are already made available by the Salesforce framework. But that doesn't mean that you cannot create your own component. The framework allows developers to create custom components.

When you begin life as a Salesforce developer you will face numerous occasions when the end users demand custom pages or something different than what Salesforce's native environment has to offer. Luckily they are easily solved by developing Visualforce pages. You can develop custom user interfaces using two ways. One by using Visualforce Components framework or use the automatically generated Page Layouts that Salesforce environment provides.


Visualforce also follows the MVC (Model View Controller) paradigm. Hence the VF pages provide tight integration with the Salesforce database.

Now let’s take a deeper look at how VF pages are built and rendered. Visualforce pages are made up of components (custom or already available). These components basically render HTML tags when called from the browser. Once the VF pages are constructed and saved in the Salesforce servers the users can access those pages using url links in the browser.  For those of you who haven’t caught on to what I have been saying he interesting part starts now. When a call is made to the Salesforce servers for those pages, the VF tags are rendered as HTML tags instead and an HTML page is displayed at the browser. (Your browser has no clue how to interpret VF tags).

You might be wondering why we need to build VF pages using VF tags then. Obviously HTML tags serve a purpose but the main advantage of using VF tags is it reduces the amount of code that needs to be written by about 90%. This is the primary reason younger Salesforce Developers like myself love the Visualforce and Apex Development platform.  This process is explained in the image below.

  

This is just a brief synopsis of the Visualforce…the next post will dive into more technical functionality….which I’m sure will be more exciting for everyone…especially you artistic types.