When a Visualforce page is loaded, the fields accessible to the page are based on the fields referenced in the Visualforce markup. But we can use StandardController.addFields(List fieldNames) method, which adds a reference to each field specified in fieldNames so that the controller can explicitly access those fields as well.
public with sharing class AccountControllerExt {
public Account acc {get; set;}
public AccountControllerExt(ApexPages.StandardController controller) {
List<String> accFieldList = new List<String>();
//Passing a list of field names to the standard controller
controller.addFields(new List<String>{'Id', 'Name', 'AccountNumber', 'Website', 'Phone','Type', 'Industry'});
//Standard controller to retrieve the field data of the record
acc = (Account)controller.getRecord();
}
}
In Winter’18 release, Salesforce has introduced lightningStylesheets attribute. To style the Visualforce page to match the Lightning Experience UI when viewed in Lightning Experience or the Salesforce app, We can set lightningStylesheets="true" in the apex:page tag. When the page is viewed in Salesforce Classic, it doesn’t get Lightning Experience styling.
Here is a standard Visualforce page with the lightningStylesheets="true" attribute in Classic View and Lightning View.
Here is an example of jQuery Data tables using in Visualforce. It will give you the pagination and search functionality in Visualforce page. Here I’m displaying list of account records.
Apex Class:
public class SampleController{
public List<Account> accList {get; set;}
public SampleController(){
accList = [SELECT Name, AccountNumber, Phone FROM Account LIMIT 10000];
}
}
<!--Check object level access within a Visualforce page-->
<apex:page>
{!$ObjectType.Contact.Accessible}
</apex:page>
<!--Check an Object field level access within a Visualforce page-->
<apex:outputText value="{!contactName}" rendered="{!$ObjectType.Contact.fields.Name.Accessible}" />
<!--Check an Object field level Update access within a Visualforce page-->
<apex:inputText value="{!contactEmail}" rendered="{!$ObjectType.Contact.fields.Email.Updateable}" />
<!--Check an Object Delete access within a Visualforce page-->
<apex:commandButton action="{!CustomDelete}" rendered="{!$ObjectType.Contact.Deletable}" />
<!-- Check an Object field level Create access within a Visualforce page .
stringToBecomeNewContactEmail is a generic string type-->
<apex:inputText value="{!stringToBecomeNewContactEmail}" rendered="{!$ObjectType.Contact.fields.Email.Createable}" />
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject