/force_platform_cookbook

Page 196

Chapter 5: Creating Public Websites

Creating a Web-to-Lead Form for Your Force.com Site Problem You want to create a web-to-lead form on your Force.com site to capture prospective customers' personal information. You also want to create a custom contact page that will appear when customers submit their information. Solution Create two Visualforce pages: one to capture a prospect's information and another to display the confirmation. You'll also need to extend the standard controller to redirect public users to a custom contact page when they submit information. First, create a Visualforce page for the confirmation: 1. Click Setup ➤ Develop ➤ Pages. 2. For the Label, enter Thank You Page and for the Name, enter ThankYou. 3. Replace the existing Visualforce markup with the following: <apex:page title="Job Application" showHeader="false" standardStylesheets="true"> <apex:composition template="{!$Site.Template}"> <apex:define name="body"> <br/> <center> <apex:outputText value="Your information is saved. Thank you for your interest!"/> </center> <br/> <br/> </apex:define> </apex:composition> </apex:page>

Next, you'll create an create an extension for the standard controller. By default in Salesforce.com, a standard controller directs the user to the standard detail page after saving the related record. However, standard detail pages can't be made public via sites. To direct users to a custom Visualforce page, you must create an extension for the standard controller. The controller extension creates a new lead record and redirects users to the “Thank You” page. To create the extension: 1. Click Setup ➤ Develop ➤ Apex Classes. 2. Click New.

190


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.