February 2013

Salesforce

Age calculation using Apex and Visualforce

Sample code: Visualforce page: <apex:page controller="Sample" ><apex:form >    <apex:pageblock >        <apex:pageblockSection >            <apex:pageblockSectionItem >Date:</apex:pageblockSectionItem>            <apex:pageblockSectionItem ><apex:inputtext onfocus="DatePicker.pickDate(true, this , false);" value="{!dat}" id="dt"/></apex:pageblockSectionItem>            <apex:pageblockSectionItem >Age:</apex:pageblockSectionItem>                                    <apex:pageblockSectionItem ><apex:outputText value="{!age}" /></apex:pageblockSectionItem>                    ....

Salesforce

apex:outputLink in Salesforce

Sample code:Visualforce page:<apex:page controller="Sample" ><apex:form >    <apex:pageBlock >        <apex:pageblockTable value="{!usrs}" var="u">            <apex:column >                <apex:outputLink target="_blank" value="/{!u.id}">{!u.Name}</apex:outputLink>            </apex:column>        </apex:pageblockTable>    </apex:pageblock>    </apex:form>    </apex:page>Apex Controller:public class Sample {     public String obj;    public ....

Salesforce

How to retrieve fields based on selected object by Dynamic Apex?

Sample Code: Visualforce page: <apex:page controller="Sample" ><apex:form >    <apex:pageBlock >        <apex:pageBlockSection >            <apex:pageBlockSectionItem >                <apex:outputLabel value="Objects"/>            </apex:pageBlockSectionItem>                    <apex:pageBlockSectionItem >                <apex:selectList size="1" value="{!obj}" >                    <apex:selectOptions value="{!objs}"/>                </apex:selectList>            </apex:pageBlockSectionItem>                              </apex:pageBlockSection>        ....