Another Salesforce blog!!!

Salesforce, Apex

VFP

Position elements side by side within a single pageBlockSection column

LINK <apex:pageBlockSection title=”Search Payment” columns=”2″ id=”pbs0″> <!–script>twistSection(document.getElementById(“{!$Component.pb0.pbs0}”).childNodes[0].childNodes[0]); </script–> <apex:inputField value=”{!PaymentResponseObj.Source_System__c}” /> <apex:inputField value=”{!PaymentResponseObj.Invoice_Number__c}” /> <!–apex:inputField value=”{!PaymentResponseObj.Invoice_Date__c}” label=”Invoice Date” /–> <!–apex:pageblockSection > <apex:inputField value=”{!PaymentResponseObj.Invoice_Date__c}” label=”From Invoice Date” /> <apex:inputText value=”{!invoiceDateTo}” id=”dateTo” label=”To Invoice Date” onfocus=”DatePicker.pickDate(false, this, false);”> <apex:param value=”{!invoiceDateTo}” /> </apex:inputText> </apex:pageblockSection–> <apex:pageBlockSectionItem> <apex:outputLabel value=”Invoice Date” for=”first” /> <apex:panelGrid columns=”2″> <apex:inputField value=”{!PaymentResponseObj.Invoice_Date__c}” style=”width: 140px;” html-placeholder=”From Invoice […]

apex:inputTextarea – required

<apex:pageBlockSection columns=”2″> <apex:PageBlockSectionItem > <apex:outputlabel value=”Amendment Justification”/> <apex:outputPanel styleClass=”requiredInput” layout=”block”> <apex:outputPanel styleClass=”requiredBlock1″ layout=”block”/> <apex:inputTextarea value=”{!o_req[‘Amendment_Justification__c’]}” cols=”70″ rows=”4″ required=”false” label=”Amendment Justification” /> </apex:outputPanel> </apex:PageBlockSectionItem> </apex:pageBlockSection>

Required InputTextArea

I was asked to make an inputtextarea required on a visualforce page and thought, “ok, no problem, 2 minutes!”. In reality, this was kind of a nightmare to implement. My vf page looked something like this: <apex:pageblock id=”pageBlock”> <apex: pagblocksection id=”pageBlockSec”> <apex:pageblocksectionitem> <apex:outputlabel value=”Big Field”> <apex:inputtextarea value=”{!myObject__c.Big_Field__c}” required = true id=”bigfield”}” … So the first […]

enum in APEX

global with sharing class My_Controller { public Case currCase {get; set; } public enum StatusValue {RED, YELLOW, GREEN} public StatusValues getColorStatus() { return StatusValue.RED; //demo code – just return red } } <apex:image url=’stopsign.png’ rendered=”{!colorStatus == StatusValue.RED}” />

Loading message using

  <apex:commabndButton value=”search” action=”{!doSearch}” reRender=”out” status=”mystatus” /> <apex:outputPanel id=”out”> <apex:actionStatus id=”mystatus”> <apex:facet name=”start”> <apex:outputText value=”loading… please wait!”</apex:outputText> </apex:facet> <apex:facet name=”stop”> <!–show the pageblock or etc… –> </apex:facet>   if you want to display the image you can do that instead of <apex:image value=”{!$Resource.loading}”</apex:outputText>

apex:actionFunction javascript

  <apex:actionFunction name=”clearFormFn” action=”{!clearForm}” status=”overlayStatus” rerender=”{!$Component.myForm}” /> <apex:actionStatus id=”overlayStatus” onstart=”showOverlay();” onstop=”hideOverlay();”/> public void clearForm() { //more code here…. } <div id=”overlay”></div> <script type=”text/javascript”> Sfdc.onReady(function() { SfdcApp && SfdcApp.Visualforce && SfdcApp.Visualforce.VSManager && SfdcApp.Visualforce.VSManager.vfPrepareForms([“myPage:myForm”]); }); </script> <script type=”text/javascript”> //——————————— // Function to display overlay div //——————————— function showOverlay() { var o = document.getElementById(‘overlay’); o.style.visibility = ‘visible’; //create […]

overriding standard page

<apex:page standardController=”name_of_the_object__c” id=”gp”> <apex:detail subject=”{!name_of_the_object__c.Id}” relatedList=”true” inlineEdit=”true” id=”detailgp”/> <apex:includeScript value=”{!$Resource.JQuery}”/> <script> var j$ = jQuery.noConflict(); j$(“iframe”).each(function(){ j$(this).load(function() { j$(this).height( j$(this).contents().find(“body”).height() ); }); }); </script> </apex:page>

apexpage message utility

public static PageReference showMessage(String message, String msgType) { ApexPages.Message msg; if(msgType == ‘Error’) { msg = new ApexPages.Message(ApexPages.Severity.ERROR, message); //error } else{ msg = new ApexPages.Message(ApexPages.Severity.INFO, message); //info } ApexPages.addMessage(msg); return null; } To use: <apex:pageMessages ></apex:pageMessages> showMessage(‘At least ‘ + count + ‘ responses required’, ‘Error’);

how to retain the checkbox selection in visualforce pagination

First off; create a wrapper class in this example I’ll be using Account standard object: Overall big picture: First on the Visualforce page create apex function with two params. Create a SET variable of id’s(Set some name = new Set) Create two properties (get; set; method properties) for Id and another for boolean. Now the […]

false postive

public Boolean isListEmpty { get{ return !(lstEmp==null || lstEmp.isEmpty()); } set; }

Previous Posts