October 2012

Salesforce

How to display Standard controller Picklist using Apex

The below code is used to display Rating picklist of standard object Account. <apex:page standardController="Account">    <apex:form >        <apex:pageMessages />        <apex:pageBlock >        <apex:pageBlockSection columns="2">            <apex:pageblockSectionItem >                <apex:outputLabel value="Rating"/>            </apex:pageblockSectionItem>        ....

Salesforce

How to disable another checkbox field checkbox if i check one checkbox in checkbox field

Sample Code: Visualforce page: <apex:page controller="sample"><script type="text/javascript"></script>       <apex:form >       <apex:pageMessages />       <apex:pageBlock >        <apex:pageBlockSection columns="2">            <apex:pageblockSectionItem >                <apex:outputLabel value="Metro"/>            </apex:pageblockSectionItem>                   <apex:pageblockSectionItem >                               <apex:inputCheckbox value="{!metro}">                                ....

Salesforce

Dynamically making a field required using Apex in Salesforce

Sample Code: Visualforce Code: <apex:page controller="sample">        <apex:form >        <apex:pageMessages/>        <apex:pageBlock>        <apex:pageBlockSection columns="2">            <apex:pageblockSectionItem>                <apex:outputLabel value="Known City"/>            </apex:pageblockSectionItem>                    <apex:pageblockSectionItem>                                <apex:inputCheckbox value="{!knwCity}">                                 <apex:actionSupport event="onchange" reRender="a"/>                </apex:inputCheckbox>            ....

Salesforce

Dependent picklist using Apex in Salesforce

Sample Code: Visualforce page: <apex:page controller="sample">        <apex:form >        <apex:pageBlock>        <apex:pageBlockSection columns="2">            <apex:pageblockSectionItem>                <apex:outputLabel value="State"/>            </apex:pageblockSectionItem>                    <apex:pageblockSectionItem>                                <apex:selectList size="1" value="{!state}">                    <apex:selectOptions value="{!states}"/>                    <apex:actionSupport event="onchange" reRender="a"/>                </apex:selectList>                            ....

Salesforce

Hide and show multiple pageBlocks in Salesforce

Sample code: Visualforce page: <apex:page controller="sample">        <apex:form >        <apex:pageBlock >        <apex:commandButton value="A Section" action="{!callA}"/>        <apex:commandButton value="B Section" action="{!callB}"/>    </apex:pageBlock>        <apex:pageBlock rendered="{!Abool}">       <apex:outputText value="This is A section"/>    </apex:pageBlock>    ....

Salesforce

How to open another Visualforce page from current Visualforce page in Salesforce?

Sample Code: Visualforce page: <apex:page controller="sample">            <apex:commandButton value="Open" action="{!openPage}"/>    </apex:page> Apex Class:  public class sample{    public pageReference openPage()     {        pageReference pg = new pageReference('/apex/Name_Of_The_Page');        pg.setRedirect(true);        return pg;    }       }