In-line Editing Visualforce Component for Any Object

19 May

This is a Visualforce component for in-line editing of an object’s child or related records. It will work for most Salesforce standard and custom objects. Pass in parameters to change what is displayed and if the user can add, edit, or delete records.

In-line Editing Visualforce Component for any object

Required Parameters

  • aParentRecId: Parent Record Id. This is used to select the related object’s records.
  • aRelationField: Field that refers back to the parent. This field is used in the query where condition with the Parent Record Id.
  • asObjectType: Type of child Object.
  • aFieldList: List of fields to display in the pageBlockTable.

Optional Parameters

  • aAllowAdd: Ability to add new records. The Add button will display.
  • aAllowEdit: Ability to edit records. The Edit link will display.
  • aAllowDelete: Ability to delete records. The Del link will display.
  • aLabelOverrideFieldList: List of fields with overridden labels.
  • aLabelOverrideTextList: List of text that overrides the field labels.
  • aDefaultValueFieldList: List of fields used to set default values on added records.
  • aDefaultValueTextList: List of text used to set default values on added records.
  • aBlockTitle: Page block title text.

Continue reading

Visualforce Table with Alphabet Filter and Sortable Columns

16 Feb

This Visualforce page contains apex:pageBlockTable to demonstrate a few different concepts.

  • Sortable Columns in an apex:pageBlockTable
  • Alphabet Filter that filters on the current sorted column
  • Use of the ApexPage StandardSetController
  • Selecting an individual record in the table using a link
  • Selecting multiple records with a column of checkboxes using a Sub Class(Wrapper Class) to hold the boolean value.

Both single and multiple record selection were included for demonstration. Most actual projects would only require one type, and I thought it would be easy to cut whatever was not needed. The search for the Billing Address fields was consolidated into one field to make the interface simpler. Below is an example of what the Visualforce table looks like with the alphabet filter, sorted columns, address search, and checkbox record selection.

Sortable apex:pageBlockTable, alphabet filter, checkbox selection and link selection
Continue reading

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


Visualforce Datepicker Manipulation and Day of Week Display

18 Dec

datepicker with past years and no date link

Hide the Datepicker Link for the Current Date

Show Years Before the Current Year in a Datepicker

Development would be a lot harder without stackexchange and stackoverflow. Thanks for this post that illustrated how to do this.

Show a Datepicker on a Text Field

Thanks to these sources for the help figuring this out.
DeveloperForce Boards

Show the Day of Week When a Date is Selected

The day of week is found by converting the input date into a datetime. Then we use the format method to give us the day of the week spelled out.

day of week spelled out

Code Examples

The examples below show how to remove the date link, show prior years in the datepicker, and add a datepicker to an field.


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