Category: visualforce

Important points to remember regarding actionRegion, actionFunction, actionSupport, actionPoller

Last night(July 17th, 2019) while preparing for Platform Developer II certification, I was going through my notes to revise the different ways to call Apex Controller functions from Visualforce page, I thought of making a post regarding actionRegion, actionFunction, actionSupport, actionPoller & actionStatus. Just setting the expectation beforehand – It is not a post which will explain you all, but I will share the developer guide link for each of them so that you can go and read them (highly recommended).actionRegionThe specifies the components to be processed on Force.com server. Without this tag, the whole page will be processed. With actionRegion also the whole form is submitted, but only the part within the tag will be processed.It needs a reRender attribute to be effective. It will only refresh the part of the page using the data contained within the tag. This can be very effectively used to avoid validation errors that may occur due to present of standard validation rule in VF page like required attribute.Here is the example without ActionRegion:Controller:public with sharing class WithoutActionRegionController { public String valueEntered{get;set;} public String country{get;set;} public String state{get;set;} public WithoutActionRegionController() { country = ”; state = ”; valueEntered = ”; } public PageReference countrySubmitted(){ valueEntered = ‘Country: ‘ + country; return null; }}Visualforce Page:<apex:page controller=”WithoutActionRegionController”> <apex:form id=”myForm”> <apex:pageMessages id=”messages1″/> <apex:pageBlock id=”topPageBlock”> <apex:pageBlockSection columns=”2″ title=”Country & State”> <apex:outputText value=”Enter Country” /> <apex:inputText value=”{!country}” > <apex:actionSupport...

Read More

Winter 18 – Automatically Styling of Existing Visualforce Pages in Lightning Experience

Salesforce Winter’18 release came with lots of surprises to all of us. Before Winter’18 release, one of the biggest pain to switch to Lightning was – How to migrate existing VisualForce pages? We all tried to use the standard VisualForce component in our VisualForce pages as a best practice till date. The reason was Salesforce’s backward compatibility. We all knew that using standard VisualForce component is safe because even if Salesforce enhances those components, we don’t need to change our VisualForce pages.But with the introduction of Lightning, things changed. People all over the world started investing in changing their existing VisualForce pages into Lightning and it is a not a very straightforward task.Salesforce realized the problem and in Winter’18 release came as a savior to all of us. With very minimum changes now, we can keep our existing VisualForce pages and it will still work in Lightning experience. This feature is still in beta mode as there are so many things to improve. But it is really a good starting point and good to know. I am quite sure Salesforce will support more and more components in coming releases. It is definitely a game changer.In this post, I will explain with an example what you need to do in your existing VisualForce page to make it work in both Lightning and Classic.I have written this below VisualForce page containing PageBlock,...

Read More

JavaScript Tips for Visualforce Developers

When I started my career 10 years back, I was first introduced to Server Side Programming. I started developing applications using Embedded C/C++. Slowly I shifted my focus towards Client Side Programming. It always motivates me if I see the end-result of my development immediately. That is how I started digging into Client Side Programmings. I always love this below quote from one of my favorite programmers – Eric ElliottIn my initial days I still remember, it was really difficult to learn JavaScript. To me, Javascript was more like a “side” language which can help implementing those functionalities which can’t be delivered by server side programming – such as DOM manipulations, browser events and things like that. So for me sending data between server and client was always a GET and POST.But I realized the power of JavaScript very soon. Trust me, with JavaScript, you can do so many things you can’t even imagine. You can not only do Client Side operations, you can perform server-side logics as well. Yes, you hear it correctly. JavaScript for Server Side Programming. With the “node.js”  you can perform server-side computations as well. But there is even more. We can now build Isomorphic applications as well. With an Isomorphic application, your initial request from the web browser will be handled by the server, but after that, any subsequent requests will be handled by...

Read More

Dynamic Apex – Playing with CRUD and FLS

Security is one of the important things in today’s world. And when we talk about cloud, Security is the top most priority items. No doubt. Salesforce is not an exception and they are also considering Security really seriously.In Salesforce, we have different types of Security controls – starting from org level security to object level, followed by record level and field level. This post focuses on methods for controlling data at the object and field level.As always I always believe explaining concept with examples is the best and effective way. Today also I will do the same thing.For this post, I have prepared a small object called Book and below is the detail -Important Note -In Visualforce, when you use any sObject or sObject field, the platform will enforce CRUD and FLS automatically. If the user is not having FLS to a field, Salesforce will automatically remove the field from the Visualforce page. For example, apex:inputField tag will be rendered as read-only for those fields having FLS set as read-only. But the exception here are the tags apex:inputText, apex:inputTextArea. Using these tags tells Visualforce to not treat them as sObject field, thus platform will not automatically enforce FLS for those  fields. Apex Code to check CRUD manually:Requirement:Write a Visualforce page with controller behind which should display all Books present in the org in the form of Picklist. When we will execute...

Read More

Dynamic Apex – Sky is The Limit – Explained with Example

Today I am going to explain Dynamic Apex with examples. Dynamic Apex will help developer to create more flexible and robust application because with the help of Dynamic Apex, developer can access the sObject and field describe information, access Salesforce application information. Another great help is that with Dynamic Apex, developer can now write dynamic SOQL, SOSL and DML statements. So basically with dynamic apex, you have the magic wand in your hand.So without any further delay, let’s start the power of magic wand.Basics of Apex Describe:In order to get information about sObjects in Salesforce, you have two options – either use tokens or use describeSObjects Schema methods.Apex provides two data structures and a method for fetching information about sObjects and fields. They are listed below -Token – This is a lightweight, serializable reference to an sObject or a field that is validated at run time. Since they are lightweight, using them make your code faster and more efficient.The describeSObjects method – This method from the Schema class will perform the describe on sObject Types.Describe result – This is basically the object of  type Schema.DescribeSObjectResult which holds the result i.e. contains all the describe properties for the sObject or field. These objects are not serializable and validated always at runtime. Let’s get into more details before we jump into the examples -Schema Describe -Schema Describe is a way to programmatically...

Read More
Loading

Earlier Posts

  • 2024 (31)
  • 2023 (47)
  • 2022 (25)
  • 2021 (35)
  • 2020 (41)
  • 2019 (13)
  • 2018 (16)
  • 2017 (14)
  • 2016 (18)
  • 2015 (74)
  • 2014 (20)