How to use reRender & rendered attributes?

reRender & rendered attributes in Salesforce

This example gives you to understand how to use reRender a field if other checkbox filed is true.

What is rendered Attribute? It is a Boolean value weather the component is rendered on visualforce page. If it is not specified, default value is always true.

What is reRender Attribute? This attribute is useful to render some other visualforce component based Boolean value.

See the below example to understand usage of reRender & rendered attributes.

Vehicle__c is a custom objected I created on my developer box. “Is_insured__c & Insured_Ammount__c” are custom fields on this custom object. “Name” is the standard name field on this custom object.

Apex Class:

public class VehicleRegisrationController {

public Vehicle__c V1 { get; set; }
public VehicleRegisrationController()
V1 = new Vehicle__c();

public void saveMethod() {
insert V1;

Visualforce Page:

<apex:page controller=”VehicleRegisrationController”>

<apex:form id=”formId”>

<apex:pageBlock >

<apex:pageBlockTable value=”{!V1}” var=”v”>

<apex:column headerValue=”Vehicle Name”>

<apex:inputField value=”{!V1.Name}”/>


<apex:column headerValue=”Is insured”>

<apex:inputField value=”{!V1.Is_insured__c}”>

<apex:actionSupport event=”onclick” reRender=”formId”/>



<apex:column headerValue=”Amount”>

<apex:inputField value=”{!V1.Insured_Amount__c}” rendered=”{!V1.Is_insured__c==true}”/>




<apex:commandButton value=”Save” action=”{!saveMethod}”/>



This is a simple example to use reRender & rendered attributes. You can leave a comment if you have any doubts.

Alert on Salesforce Standard/Custom object Page Layouts?

How to display alert on Salesforce Standard/Custom object Page Layouts?

This post describes how to display alert on Standard or/custom page layouts based on specific field value. Here I am going to explain this scenario for Account Layout. If I open an account record where “Display_Alert__c” equals true, I need a pop to display.

To achieve this we need to create a visualforce to display popup. And place this visualforce page on page layout you want to display.

Fallow below steps to implement this solution.

  1. I have created a custom field on Account object with data type checkbox. Field name is “Display_Alert__c”
  2. Create a visualforce page “AccountAlertLayoutPage” to display alert. I created this page with below code.

<apex:page standardController=”Account”>



            alert(‘Display Alert!!’);



  1. Next go to Account page Layout and add visualforce page created above to the Account PageLayout.

Setup -> Customize -> Account -> Page Layout


Click Edit next to the page layout and add visualforce. Click on visualforce settings change width & height to “0”. And also uncheck “show scrollbars & show labels”.

Alerts 24. Save page layout.

To test this Create an Account record with required fields and also check “Display_Alert__c” checkbox. Next open this record, you will get alert checkbox.

Alert 4

You can change popup message on visualforce page based on your requirement. You can implement this for any type of field based on your requirement. And you can implement your own visualforce based on your requirement.