Disable Visualforce Buttons When Processing – apex:actionStatus

27 Dec

It is very handy to disable buttons after they have been pressed. This lets the user know that the button was in fact pressed, and it prevents the button’s action from being executed multiple times. The Visulforce component apex:actionStatus gives us an easy way to accomplish this. Here are some things to take note of in the example.

  • The command button must have a rerender parameter
  • Command buttons must be in an apex:outputPanel, so both buttons appear on the page when each apex:facet is active.
  • The action status will only disable one set of buttons for a apex:pageBlock at a time. If ‘both’ is specified for the button location, only the clicked set of buttons on top or bottom will be disabled while processing. I usually select only one location to prevent additional button clicks.
  • Add the immediate=”true” attribute to the Cancel. This bypasses Visualforce validation that would normally fire on the form.

active buttons
disabled buttons



Multiselect Picklists for User Search and Selection using Apex and Visualforce

9 Dec

Below is a component that will allow you to search and select Users. It was created to mimic the experience of selecting multiple users in the Task creation window. However, it would be easy to change the reference from the User object to almost any other object.

An initial list of selected users can be assigned by passing an Id list in the component attribute aInitialRightList. The list referenced in the aCurrentRightList attribute will be updated anytime entries in the right multiselect picklist change. The aWidth attribute accepts px or %, and it sets the width of the entire component.

I’d like to thank those who posted sample code that helped me with the multiselect picklist component. I borrowed ideas and code from the following:
Custom Multi-Select picklist field in Visualforce
A Multiselect Picklist Visualforce Component

Multi Select Picklist Visualforce Component Example






Record ID and Data Retrieval from a VisualForce Controller Extension without a SOQL statement

26 Nov

Retrieve field data for a record using the Standard Controller object in a Controller Extension class

Salesforce Documentation:
Standard Controller Class
StandardController Instance Methods

Visualforce Help Text and a Popup Tool Tip

21 Oct

Visualforce Field Help Text

The help icon can be added to a Visualforce field within an apex:pageBlockSectionItem. Access the help text using the $ObjectType api. Put it in the helptext attribute of the apex:pageBlockSectionItem.

Easy Hover Tooltip

The following may help if you are not using the apex:pageBlockSectionItem. I’ve used this technique in the past to put help text on an image in a apex:pageBlockTable and on plain text in a page.


Hover Over Me
your message here

Thanks to www.kollermedia.at/archive/2008/03/24/easy-css-tooltip/ for providing an easy way to add tooltip help. He does it by putting the style on the link tag instead of the div.

March 16, 2014: Here is another tutorial that explains how to do a popup tool tip. Tutsplus – Tooltip

Define and Initialize a Map, List, and Set in Apex

20 Oct

The syntax for defining a list, map, and set collection with initial values sometimes slips my mind. The lack of () throws me off, so this post is to help out my future self.

List Definition

Set Definition

Map Definition

Defining a List of Maps

Defining a Map of Lists

Defining a Map of Maps

Sample logic to retrieve the nested Map’s value

This function accepts Param1 as the key for the outer map. Param2 is the key for the inner map. TheMap is a map that contains a nested map which will be worked with. First, we see if there is a key value in the outer map that matches Param1. When it contains the key, the next statement creates a reference to the inner map in the variable TempMap. TempMap is checked for the value of Param2, and the value is returned when found. Finally, null is returned when there is not a match.