Posts

Showing posts from 2011

Salesforce Data collections List ,Set ,Map

In Salesforce Apex, data collections such as lists, sets, and maps are used to store and manipulate data. These collections offer different functionalities and are suited for different use cases. Here's an overview of each:  List : A list is an ordered collection of elements where each element has an index. Lists allow duplicate elements. Elements in a list can be accessed using their index. Lists are represented by the List class in Apex. Example : List<String> names = new List<String>(); names.add('Alice'); names.add('Bob'); names.add('Alice'); // Adding duplicate element System.debug(names); // Output: (Alice, Bob, Alice) Set : A set is an unordered collection of unique elements. It does not allow duplicate elements. Sets are useful when you need to ensure uniqueness and don't require the elements to be in a specific order. Sets are represented by the Set class in Apex. Example : Set<String> uniqueNames = new Set<String>(); uni...

Dynamic Menu Using JDock

Image
Show Sleek and Dynamic Menu on the Visualforce Page. jqdock is a jQuery plugin inspired by Mac .jqdock is a jQuery plugin inspired by Mac Dock Menu. jqDock   Visualforce Page <apex:page sidebar="false" showHeader="false" controller="JqueryController">  <head>    <style> bPageHeader{       display:none;   }   .heading{       background-color:#ccc;       text-align:center;   }   .data table,td,th {       border:1px solid #000;   }   </style>  <apex:includeScript value="{!$Resource.jquery}"/>  <apex:includeScript value="{!$Resource.jqDock}"/>   <style type='text/css'>  /*position and hide the menu initially - leave room for menu items to expand...*/ #page {padding-top:150px; padding-bottom:20px; width:100%;} #menu {position:absolute; top:0; left:0; width:100%; display:none;} /*dock styling...*/ /*...centre the dock...*/ ...

Master-Detail and Lookup relationships in Salesforce

Image
In Salesforce, Master-Detail and Lookup relationships establish relationships between objects. Here's an explanation of each: Dependency and Data Integrity: Master-Detail Relationship: Child records are tightly bound to parent records. If a parent record is deleted, all associated child records are deleted. This ensures strong data integrity and dependency between records. Lookup Relationship: Child records can exist independently of parent records. Deleting a parent record does not automatically delete associated child records. This offers more flexibility but results in weaker data integrity than Master-Detail relationships. Ownership and Control: Master-Detail Relationship: The parent object owns the relationship, and the child object is subordinate. The child record inherits security and sharing settings from the parent record. Master-detail relationships are typically used for objects with a clear parent-child relationship where the parent owns the child's records. Lookup ...

Visualforce Best Practices

Visualforce is a powerful framework for building user interfaces in Salesforce applications. Here are some best practices to keep in mind when working with Visualforce: Best Practices for Improving Visualforce Performance Best Practices for Accessing Component IDs Best Practices for Static Resources Best Practices for Controllers and Controller Extensions Best Practices for Using Component Facets Best Practices for Page Block Components Best Practices for Rendering PDF Files Rendering a Visualforce page as a PDF file is a great way to share information about your Salesforce organization. Here are some best practices for you to consider. Best Practices for <apex:panelbar> Documentation Typographical Conventions 

Salesforce MVC Architecture

Salesforce MVC Architecture Salesforce uses a Model-View-Controller (MVC) architecture, which is a software design pattern that separates the representation of information (the model) from the user's interaction with it (the view and the controller) Salesforce Platform Architecture The Salesforce platform uses a multi-tenant, metadata-driven architecture, which allows for high customization and extensibility.  This architecture includes: A single instance of the Salesforce kernel that serves all tenants Tenant-specific metadata that is used to dynamically materialize applications Comprehensive testing and deployment processes to ensure reliability Overall, Salesforce's MVC architecture, combined with its multi-tenant, metadata-driven platform, enables the development of highly customizable, scalable, and maintainable applications. Key Components of Salesforce MVC: Model (Database Layer) : The schema and data in Salesforce, represented by sObjects (Salesforce objects). This is t...

Apex Page Message in Visualforce

To display a page message on a Visualforce page, you can use the <apex:pageMessages> component. This component is typically used to display messages to users, such as validation errors, informational messages, or confirmation messages. Here's how you can use it: <apex:page controller="YourControllerName">     <!-- Your Visualforce page content goes here -->          <!-- Page messages section -->     <apex:pageMessages /> </apex:page> Within your Apex controller or controller extension, you can add messages to be displayed using the Apex addError() method. For example: public class YourControllerName {     public PageReference yourActionMethod() {         // Perform some action                  // Add a message         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Your message here.')); ...

What Is Visualforce Tabs?

Tabs in vf page are used to display content like the way standard tabs do. Each tab do consist of its individual section, which is display some content. To create a tab like view, we use <apex:tabPanel> and <apex:tab> tags. Example code for Tabs in Visualforce <apex:page> <apex:tabPanel switchType="client"> <apex:tab label="Tab 1"> <!-- Content for Tab 1 --> </apex:tab> <apex:tab label="Tab 2"> <!-- Content for Tab 2 --> </apex:tab> <apex:tab label="Tab 3"> <!-- Content for Tab 3 --> </apex:tab> </apex:tabPanel> </apex:page> In this <apex:tabPanel> tag is used in which each <apex:tab> tag consist of information to be displayed in the tab.

Order of Execution in a Visualforce Page

In Visualforce, the order of execution refers to the sequence in which various components and actions are processed when a Visualforce page is loaded and rendered. Understanding this order is crucial for developers to control the behavior and appearance of their Visualforce pages effectively. Here's the typical order of execution: Component Initialization: First, any components defined in the Visualforce page are initialized. This includes standard components like <apex:page>, <apex:form>, and custom components. Controller Initialization: If the Visualforce page has a controller or controller extension associated with it, the constructor of the controller(s) is executed. This allows the controller to initialize any necessary data or perform any required setup operations. Getter Methods Execution: After the controller is initialized, getter methods defined in the controller are executed. Getter methods are responsible for providing data to the Visualforce page, typically...

What are Custom Controllers , Custom List Controller and Controller Extensions?

A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user. Example <apex:page controller="myController" tabStyle="Account">     <apex:form>         <apex:pageBlock title="Congratulations {!$User.FirstName}">             You belong to Account Name: <apex:inputField value="{!account.name}"/>             <apex:commandButton action="{!save}" value="save"/>         </apex:pageBlock>     </apex:form> </apex:page> public class MyController {     private final Account account;     public MyController() {         account = [SELECT Id, Name, Site FROM Acco...

Floating Menu on Visualforce Page

Image
Here's an example to create a floating menu. <apex:page > <html> <body> <style> div.floating-menu {position:fixed;background:#fff4c8;border:1px solid #ffcc00;width:150px;z-index:100;} div.floating-menu a, div.floating-menu h3 {display:block;margin:0 0.5em;} </style> <div class="floating-menu"> <h3>Floating Menu</h3> <a href="http://www.quackit.com/css/">CSS</a> <a href="http://www.quackit.com/html/">HTML</a> <a href="http://www.quackit.com/javascript/">JavaScript</a> <a href="http://www.quackit.com/coldfusion/">ColdFusion</a> <a href="http://www.quackit.com/myspace/codes/">MySpace Codes</a> </div> </body> </html> </apex:page> 

What Is Standard Controller In Visualforce?

In Visualforce, a standard controller is a pre-built Apex controller provided by Salesforce that allows developers to work with standard database objects (such as records from Salesforce objects like Account, Contact, Opportunity, etc.) without having to write custom Apex code. Standard controllers provide basic CRUD (Create, Read, Update, Delete) operations and other standard functionality for interacting with these objects in Visualforce pages. When using a standard controller in Visualforce, you can directly reference fields and perform operations like saving records without explicitly writing Apex code. Standard controllers also handle security and access permissions automatically, ensuring that users only have access to the records they are authorized to view or modify. Here's a basic example of using a standard controller in Visualforce: <apex:page standardController="Account">     <apex:form>         <apex:inputField value="{!Account.N...

What Is Standard List Controllers In Visualforce?

Standard List Controllers in Visualforce provide developers with a way to display lists of records from standard or custom Salesforce objects without the need for writing Apex code explicitly. These controllers come pre-built with basic functionality for navigating, filtering, and working with collections of records. Here are some key points about Standard List Controllers: Built-in CRUD Operations: Standard List Controllers provide basic CRUD operations (Create, Read, Update, Delete) out-of-the-box, allowing users to view, edit, and delete records directly from Visualforce pages without writing custom Apex code. Automatic Pagination: When displaying a large set of records, Standard List Controllers automatically handle pagination, splitting the records into manageable chunks and providing navigation controls for users to navigate between pages. Sorting and Filtering: Standard List Controllers offer built-in support for sorting and filtering records based on various criteria, such as f...

Where Can Visualforce Pages Be Used?

Developers can use Visualforce pages to: Override standard buttons, such as the New button for accounts, or the Edit button for contacts Override tab overview pages, such as the Accounts tab home page Define custom tabs Embed components in detail page layouts Create dashboard components or custom help pages Customize, extend, or integrate the sidebars in the Salesforce console (custom console components) Add navigation menu items and actions in the Salesforce mobile app

What is Visualforce Controllers ?

A Visualforce controller is a set of instructions for what happens when a user interacts with components specified in associated Visualforce markup. One type of interaction is when a user clicks a button or link. Controllers also provide access to the data displayed in a page, and can modify component behavior. A developer can either use a standard controller provided by Lightning Platform, or add custom controller logic with a class written in Apex: A standard controller consists of the same functionality and logic that is used for a standard Salesforce page. For example, if you use the standard Accounts controller, clicking a Save button in a Visualforce page results in the same behavior as clicking Save on a standard Account edit page. If you use a standard controller on a page and the user doesn't have access to the object, the page displays an insufficient privileges error message. Resolve this error by checking the user's accessibility for an object and displaying compo...

How is Visualforce Architected?

Image
All Visualforce pages run entirely on the Lightning platform, both when a developer creates the page, and when an end user requests a page, as shown in the following architecture diagrams. Visualforce System Architecture - Development Mode   When a developer finishes writing a Visualforce page and saves it to the platform, the platform application server attempts to compile the markup into an abstract set of instructions that can be understood by the Visualforce renderer. If compilation generates errors, the save is aborted and the errors are returned to the developer. Otherwise, the instructions are saved to the metadata repository and sent to the Visualforce renderer. The renderer turns the instructions into HTML and then refreshes the developer's view, thereby providing instantaneous feedback to the developer for whatever changes were made in the markup. The architecture diagram below shows the process flow when a non-developer user requests a Visualforce page. Because the page ...

What is a Visualforce Page?

Visualforce Page is a framework that allows developers to create custom user interfaces for applications hosted on the Salesforce platform. A Visualforce page is a markup language that defines the layout and behavior of a web page within the Salesforce environment. Here are some key points about Visualforce pages: Custom User Interfaces: Visualforce pages allow developers to create custom user interfaces using a combination of HTML, CSS, and a tag-based markup language specific to Salesforce. Integration with Apex: Visualforce pages can be integrated with Apex, Salesforce's proprietary programming language. This allows developers to create dynamic and interactive pages by incorporating server-side logic. Data Binding: Visualforce pages can bind to Salesforce data, enabling developers to display, manipulate, and interact with data from Salesforce objects such as accounts, contacts, leads, and custom objects. Component-Based Architecture: Visualforce follows a component-based archite...

Getting started with Visualforce

Image
What is Visualforce? Visualforce is a web development framework that enables developers to build sophisticated, custom user interfaces for mobile and desktop apps that can be hosted on the Lightning Platform. You can use Visualforce to build apps that align with the styling of Lightning Experience, as well as your own completely custom interface. Visualforce enables developers to extend Salesforce’s built-in features, replace them with new functionality, and build completely new apps. Use powerful built-in standard controller features, or write your own custom business logic in Apex. You can build functionality for your own organization, or create apps for sale in the AppExchange. Visualforce app development is familiar to anyone who has built web apps. Developers create Visualforce pages by composing components, HTML, and optional styling elements. Visualforce can integrate with any standard web technology or JavaScript framework to allow for a more animated and rich user interface. E...