How to override field labels in visualforce page

How to override field labels in visualforce page? <apex:page standardController=”Account” recordSetVar=”accs”> <apex:form > <apex:pageBlock title=”Std List Controller Demo”> <apex:pageBlockTable value=”{!accs}” var=”a”> <!– how to override the sObject label using facet–> <apex:column value=”{!a.Name}”> <apex:facet name=”header”>Company Name</apex:facet> <!– header footer caption –> </apex:column> <apex:column headerValue=”Industry”> <apex:inputField value=”{!a.Industry}”/> </apex:column> <apex:column value=”{!a.Phone}”/> <!– how to override the sObject label –> <apex:column headerValue=”Company Type” value=”{!a.Type}”/> </apex:pageBlockTable> <apex:pageBlockButtons > <apex:commandButton value=”Update” action=”{!save}”/> <apex:commandButton value=”Next” action=”{!Next}”/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>

Read More

Difference – pageBlockTable, dataTable, dataList and Repeat in Visualforce Page

Difference – pageBlockTable, dataTable, dataList and Repeat in Visualforce Page <apex:page standardController=”Account” recordSetVar=”Accounts”> <apex:form > <apex:pageBlock title=”pageBlockTable Demo”> <apex:pageBlockTable value=”{!Accounts}” var=”a” border=”1″ cellpadding=”1″> <apex:facet name=”caption”>Account Records</apex:facet> <apex:column headerValue=”Name” value=”{!a.Name}”/> <apex:column value=”{!a.Industry}”> <apex:facet name=”header”>Industry</apex:facet> </apex:column> <apex:column value=”{!a.Phone}”> <apex:facet name=”header”>Phone</apex:facet> </apex:column> <!–<apex:facet name=”footer”>Account Records Ends</apex:facet> –> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title=”DataTable Demo”> <apex:dataTable value=”{!Accounts}” var=”a” border=”1″ cellpadding=”1″> <apex:facet name=”caption”>Account Records</apex:facet> <apex:column headerValue=”Name” value=”{!a.Name}”/> <apex:column value=”{!a.Industry}”> <apex:facet name=”header”>Industry</apex:facet> </apex:column> <apex:column value=”{!a.Phone}”> <apex:facet name=”header”>Phone</apex:facet> </apex:column> <!–<apex:facet name=”footer”>Account Records Ends</apex:facet> –> </apex:dataTable> </apex:pageBlock> <apex:pageBlock title=”Datalist Demo”> <apex:dataList value=”{!Accounts}” var=”a”> <apex:outputField value=”{!a.Industry}”/> </apex:dataList> </apex:pageBlock> <apex:pageBlock title=”repeat Demo”>…

Read More

How to read write values between Visualforce page and Apex

How to pass values between Visualforce page and Apex Apex Class: public class DemoController { public String name {get; set;} public String city {get; set;} public DemoController(){ name = ‘Ranjith’; city = ‘Chennai’; } }   Visualforce: <apex:page controller=”DemoController”> <apex:form > <apex:pageBlock > {!name} <br/> {!city} </apex:pageBlock> </apex:form> </apex:page>  

Read More

Refresh part of visualforce using reRender

Refresh part of visualforce using reRender Apex Class public with sharing class ActionDemoController { public String name {get; set;} public void show(){ name = ‘inside the show method’; } } Visualforce <apex:page controller=”ActionDemoController” id=”page”> <!– to refresh part of the page, use the reRender attribute along with action component –> <apex:form id=”fm” title=”main block”> <apex:pageBlock id=”pb1″> <apex:commandButton value=”call show” action=”{!show}” reRender=”pb2″/> </apex:pageBlock> <apex:pageblock title=”result” id=”pb2″> {!name} </apex:pageblock> </apex:form> </apex:page>

Read More

Salesforce Interview Questions

Salesforce Interview Question 1. What is the maximum size of the list? 2. What are the map methods in Apex? 3. What is SOQL? 4. What is SOSL? 5. Salesforce Soql And Sosl Governor Limits? 6. Difference between insert and Database.insert? 7. What are the DML statements available in Apex? 8. Governor Limits for DML statements? 9. What are the trigger events? 10. When to use before triggers and when to use after triggers? 11. What are the trigger context variables? 12. What is the difference between trigger.new and trigger.old…

Read More

Apex Trigger Salesforce

Triggers Apex Code that can be invoked based on a DML event. DML Events Insert Update Delete Upsert Trigger Types Triggers are categorized as two types 1. Before 2. After Hence the triggers would be invoked based on DML events as below, Before / After Insert Before / After Update Before / After Delete After Undelete Trigger Syntax: trigger triggerName on ObjectName (DML_Events){ //code_block } trigger is a key word. DML_Events as specified above (one event or more than one). Example scenarios when we can use triggers. 1. Block users…

Read More

Create tab interface in a visualforce page

<apex:page standardController=”Account”> <apex:tabPanel selectedTab=”Tab1″> <apex:tab label=”Account” name=”A”> <apex:detail subject=”{!account}” relatedList=”false”/> </apex:tab> <apex:tab label=”Contact” name=”Tab2″> <apex:relatedList subject=”{!account}” List=”Contacts”/> </apex:tab> <apex:tab label=”Opportunity” name=”Tab3″> <apex:relatedList subject=”{!account}” List=”Opportunities”/> </apex:tab> </apex:tabPanel> </apex:page>

Read More

Call controller method from tab component

How to call controller method from tab component in visualforce? Apex: public with sharing class tabController2 { public list<account> accList {get; set;} public list<contact> conList {get; set;} public tabController2(){ accList = [select name from account where industry = ‘energy’]; } public void contactRec(){ conList = [select lastName from contact]; } }   Page: <apex:page controller=”tabController2″> <script> // jsFunc is called from tab2 (referred by id in apex:tab) function jsFunc(){ actionfun(); } </script> <apex:form > <apex:tabPanel id=”tabP” switchType=”ajax”> <apex:tab label=”Energy Accounts”> <apex:pageblock > <apex:pageblockTable value=”{!accList}” var=”a”> <apex:column value=”{!a.name}”/> </apex:pageblockTable> </apex:pageblock> </apex:tab>…

Read More

Arrays in Apex

Arrays: Array can hold collection of similar elements.  Each element in the array is located by index. Index value starts with zero. So the first element occupies the index zero. Syntax: datatype[] arrayName;  // the square brackets [] is the notation used to declare an array Where the dataType can be primitive (such as Integers or Strings), sObject (Account or Contact or ay custom object etc.,) or userdefined (variable of class type) types. Example: Integer[] ages;     // 30, 40, 50.. String[]  names;   // ‘ranjith’, ‘krishnan’ Account[] accs; Position__c[] pos;  //…

Read More