Book Image

Learning Apex Programming

5 (1)
Book Image

Learning Apex Programming

5 (1)

Overview of this book

Table of Contents (17 chapters)
Learning Apex Programming
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Extending control


There are times where it might make more sense to use a custom controller, for example, if the page is not tied to a specific type of sObject. However, there are also times where the page is tied to a specific type of sObject and the standard controller makes more sense, but you just need one extra bit of data or functionality. Unfortunately, pages can only use either a standard controller or a custom controller, but not both.

Don't worry though, there's a simple solution. While you cannot use both a standard controller and custom controller, you can extend either of them with a controller extension. As you probably guessed, an extension is just an Apex class that follows certain syntax. Extensions really do allow you to have the best of both worlds. You can use the built-in functionality and only write code for what's not included. Your pages can actually use multiple extensions; this allows you to write reusable functionality that can be used across multiple pages.

Let...