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

Controlling components


Components are not just for static markup. A component can have its own controller that enables users to interact with it. This is useful for web functions that occur on multiple screens, such as a search bar that only searches through records of the sObject in the standard controller. It's also useful for web functions that occur multiple times on a single page. A great example is uploading files. Normal behavior on the Salesforce1 Platform is to upload one file at a time. Most people are okay with this, but sometimes when you're uploading a long list of files, you might forget which ones you've already done. You could just use a Visualforce page with a bunch of <apex:inputFile> tags on it, but wouldn't it be so much cooler to perfect your upload user interface in a component and then reuse that component multiple times on the same page? Let's start by creating an Apex class named fileUploaderComponentController:

public with sharing class fileUploaderComponentController...