Slaesforce FAQ

how to save the data using custom controller in salesforce

by Kris Oberbrunner Published 2 years ago Updated 1 year ago
image

The custom controller method in Salesforce must be referenced with {!}. {!User.Firstname} – This method retrieves the firstname of the User. In above apex class, getAccount method is referenced by <apex:inputfield> tag in visualforce page and <apex:commandButton> tag references the save method with its action attribute.

Full Answer

How to create and use custom controllers in Salesforce?

Create & Use Custom Controllers 1 Beyond the Basics. You might have noticed that this custom controller class doesn’t inherit from another class, nor does it implement an interface promising to conform to the requirements of ... 2 Add a Method to Retrieve Records. ... 3 Beyond the Basics. ... 4 Tell Me More... ...

How do I create a contact list controller in Salesforce apex?

Open the Developer Console and click to create a new Apex class. Enter ContactsListController for the class name. In the editor, replace any code with the following. public class ContactsListController { // Controller code goes here }. As with Visualforce pages, you need to save your changes to Apex when you change it.

What can you do with custom controllers?

Tell Me More... Custom controllers and the Apex language let you do pretty much anything you can think of in your Visualforce pages. Getter methods pull data out of your controller onto your page. There are corresponding setter methods that let you submit values from the page back up to your controller.

How do I use the custom controller with the page?

The custom controller is associated with the page because of the controller attribute of the <apex:page > component. As with standard controllers and controller extensions, custom controller methods can be referenced with {! } notation in the associated page markup.

image

How do I add data to a custom controller in Salesforce?

You need to use tag. It is a section of a Visualforce page that allows users to enter input and then submit it with an or . Also, I suggest to use tag.

Can we use extension with custom controller?

A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when: You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.

How do I create a custom controller in Salesforce?

To create Custom controller navigate to Setup | Build | develop | Apex Classes | New. Click on Version settings before creating Custom controller in Salesforce. This version settings specify version of Apex and the API used. Now click on Apex class editor to write Apex class for Custom controller in Salesforce.

What is the difference between standard and custom controller in Salesforce?

There are number of standard controllers exists for each Salesforce object which provides the functionality similar to custom controller. A custom controller is the user defined an Apex class that implements all of the logic for a page without leveraging a standard controller.

What is difference between controller and extension?

A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when:You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete. You want to add new actions.

What is StandardSetController why we use it?

StandardSetController allows us to create list controllers similar to, or as extensions of, the pre-built Visualforce list controllers provided by Salesforce.

What is StandardController in Salesforce?

Standard Controller in Salesforce provides the ability to access and interact with structures business data contained in records and displays the data in the proper user Interface. StandardController attribute must be used on tag.

What is SOSL in Salesforce?

Salesforce Object Search Language (SOSL) is a Salesforce search language that is used to perform text searches in records. Use SOSL to search fields across multiple standard and custom object records in Salesforce. SOSL is similar to Apache Lucene.

What is recordSetVar in Salesforce?

The recordSetVar attribute indicates that the page uses a list controller and the variable name of the record collection. This variable can be used to access data in the record collection.

When should an extension be used instead of a custom controller?

Use controller extensions when: You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete. You want to add new actions. You want to build a Visualforce page that respects user permissions.

What is extension of Apex in Salesforce?

Controller extension in Salesforce is an Apex class containing a constructor that is used to add or extend the functionalities of a Standard Controller or custom controller in Salesforce. Extension controller is also used to leverage the functionality of another controller using our own custom logic.

What is ViewState in Salesforce?

View state holds the state of Visual force page. The view state of a web page is composed of all the data that's necessary to maintain the state of the controller during server requests (like sending or receiving data).

What is custom controller?

A custom controller is an Apex class that uses the default, no-argument constructor for the outer, top-level class. You cannot create a custom controller constructor that includes parameters.

Can you use user credentials to execute controller logic?

Consequently, the current user's credentials are not used to execute controller logic, and the user's permissions and field-level security do not apply. You can choose whether a custom controller respects a user's organization-wide defaults, role hierarchy, and sharing rules by using the with sharing keywords in the class definition.

Introduction to Custom Controllers

Custom controllers contain custom logic and data manipulation that can be used by a Visualforce page.

Create a Visualforce Page that Uses a Custom Controller

Add a custom controller to a Visualforce page by referencing the name of the controller class in the <apex:page> controller attribute.

Create a Custom Controller Apex Class

A custom controller is just an Apex class, which you write yourself using the Developer Console.

Beyond the Basics

You might have noticed that this custom controller class doesn’t inherit from another class, nor does it implement an interface promising to conform to the requirements of a Visualforce controller. Even complex controllers don’t do these things, because there isn’t any such class to inherit from or interface to implement.

Add a Method to Retrieve Records

Create a getter method that runs a SOQL query that returns records you want to display on your page.

Add a New Action Method

Create action methods in your custom controller to respond to user input on the page.

Beyond the Basics

The header text for the first name and last name columns is hard-coded in this markup. But what if your users don’t all use English? The standard Salesforce user interface has translated versions of the field names for all standard objects, and you can provide your own translations for custom objects.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9