How to include commandButton in a visualforce page

How to include commandButton in a visualforce page <apex:page > <apex:form > <apex:pageBlock title=”CommandButton Demo 1″> <apex:pageBlockButtons > <apex:commandButton value=”Save” /> </apex:pageBlockButtons> </apex:pageBlock> <apex:pageBlock title=”CommandButton Demo 2″> <apex:commandButton value=”Cancel” /> </apex:pageBlock> <apex:pageBlock title=”CommandButton Demo 3″> <apex:commandButton value=”disable” disabled=”true”/> <apex:commandButton value=”URL” action=”https://ap5.salesforce.com”/> <apex:commandButton value=”CSSDemo” style=”color:red;”/> <apex:commandButton value=”rendered” rendered=”false”/> </apex:pageBlock> <apex:pageBlock title=”Rendered Demo” rendered=”{!NOT(FALSE)}”> <apex:commandButton value=”Demo” /> <apex:outputLabel rendered=”{!ISBLANK(‘Ranjith’)}”>My Text</apex:outputLabel> </apex:pageBlock> </apex:form> </apex:page>

Read More

Custom picklist, Radio button, Checkbox in Visualforce Page

Custom picklist, Radio button, Checkbox in Visualforce Page <apex:page > <apex:form > <apex:pageBlock title=”picklist demo!”> <apex:pageBlockSection title=”DropDown Demo”> <apex:pageBlockSectionItem > <apex:outputLabel value=”City”></apex:outputLabel> <apex:selectList size=”1″ > <apex:selectOption itemLabel=”Chn” itemValue=”Chennai”></apex:selectOption> <apex:selectOption itemLabel=”Hyd” itemValue=”Hyderabad”></apex:selectOption> <apex:selectOption itemLabel=”Bng” itemValue=”Bengaluru”></apex:selectOption> </apex:selectList> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title=”Multi Picklist Demo”> <apex:pageBlockSectionItem > <apex:outputLabel value=”City”></apex:outputLabel> <apex:selectList multiselect=”true” size=”3″ > <apex:selectOption itemLabel=”Chn” itemValue=”Chennai”></apex:selectOption> <apex:selectOption itemLabel=”Hyd” itemValue=”Hyderabad”></apex:selectOption> <apex:selectOption itemLabel=”Bng” itemValue=”Bengaluru”></apex:selectOption> </apex:selectList> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title=”RadioButtons”> <apex:pageBlockSectionItem > <apex:outputLabel value=”City”></apex:outputLabel> <apex:selectRadio > <apex:selectOption itemLabel=”Chn” itemValue=”Chennai”></apex:selectOption> <apex:selectOption itemLabel=”Hyd” itemValue=”Hyderabad”></apex:selectOption> <apex:selectOption itemLabel=”Bng” itemValue=”Bengaluru”></apex:selectOption> </apex:selectRadio> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title=”CheckBoxes”> <apex:pageBlockSectionItem > <apex:outputLabel value=”City”></apex:outputLabel> <apex:selectCheckboxes > <apex:selectOption…

Read More

Standard Controller Visualforce Page – pageBlockButton

<apex:page standardController=”Account”> <apex:form > <apex:pageBlock title=”Account Entry Block”> <apex:pageBlockButtons > <apex:commandButton value=”save” action=”{!save}”/> </apex:pageBlockButtons> <apex:pageBlockSection > <apex:inputField value=”{!Account.Name}”/> <apex:inputField value=”{!Account.type}”/> <apex:inputField value=”{!Account.Industry}”/> <apex:inputField value=”{!Account.Phone}”/> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title=”Location Demo”> <apex:pageBlockButtons location=”bottom”> <!– bottom top both –> <apex:commandButton value=”Button1″/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>

Read More

List Controller – display list of records in visualforce standarad controller

List Controller – display list of records in visualforce standarad controller For Account <apex:page standardController=”Account” recordSetVar=”accs”> <apex:form > <apex:pageBlock title=”Std List Controller Demo”> <apex:pageBlockTable value=”{!accs}” var=”a”> <apex:column value=”{!a.Name}”/> <apex:column value=”{!a.Industry}”/> <apex:column value=”{!a.Phone}”/> <apex:column value=”{!a.Type}”/> </apex:pageBlockTable> <apex:pageBlockButtons > <apex:commandButton value=”Next” action=”{!Next}”/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page> For Opportunity: <apex:page standardController=”Opportunity” recordSetVar=”Opps”> <!– Pagination in Standard List Controller –> <apex:form > <apex:pageBlock title=”Std List Controller Demo”> <apex:pageBlockTable value=”{!Opps}” var=”op”> <apex:column value=”{!Op.Owner.Name}”/> <apex:column value=”{!op.Name}”/> <apex:column value=”{!op.StageName}”/> <apex:column value=”{!op.CloseDate}”/> <apex:column value=”{!op.Amount}”/> </apex:pageBlockTable> <apex:pageBlockButtons > <apex:commandButton value=”Prev” action=”{!Previous}”/> <apex:commandButton value=”Next” action=”{!Next}”/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>

Read More

Referring related parent Object fields in Visualforce page

<apex:page standardController=”Contact”> <!– Pagination in Standard List Controller –> <apex:form > <apex:pageBlock title=”Contact Page”> <apex:pageblocksection columns=”1″> <apex:outputField value=”{!Contact.FirstName}”/> <apex:outputField value=”{!Contact.LastName}”/> <apex:outputField value=”{!Contact.Account.Name}”/> </apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>

Read More

Edit the record in list controller visualforce page

Edit the record in list controller visualforce page <apex:page standardController=”Account” recordSetVar=”accs”> <apex:form > <apex:pageBlock title=”Std List Controller Demo”> <apex:pageBlockTable value=”{!accs}” var=”a”> <apex:column value=”{!a.Name}”/> <apex:column > <apex:inputField value=”{!a.Industry}”/> </apex:column> <apex:column value=”{!a.Phone}”/> <apex:column 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

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