I have Created the Visualforce Page and apex class which Means Controller Class to count the Viewers of users using the Visualforce Page
<apex:page sidebar="false" showheader="false" StandardController="Page_View__c" extensions="DisplayPage" action="{!TotalRecordUpdate}">
<apex:pageBlock >
<apex:form />
<apex:pageBlockSection >
title="your record details of ID:{!CurrentRecordID}"
</apex:pageBlockSection>
</apex:pageBlock>
<apex:outputField value="{!Page_View__c.Count__c}" />
</apex:page>
Apex Class;
public class DisplayPage {
public string CurrentRecordID {get;set;}
public list<Page_View__c> viewList {get;set;}
public static string CurrentRecordID1 {get;set;}
public DisplayPage(ApexPages.StandardController Controller) {
CurrentRecordID = ApexPages.currentPage().getparameters().get('id');
system.debug(CurrentRecordID);
viewList = [select id, Count__c from Page_View__c where id =: CurrentRecordID];
system.debug(viewList);
DisplayPage.TotalRecordUpdate();
}
public static void TotalRecordUpdate() {
CurrentRecordID1 = ApexPages.currentPage().getparameters().get('id');
List < Page_View__c > totalupdate = new List < Page_View__c > ();
List < Page_View__c > recDetails = [select id, Count__c from Page_View__c where id =: CurrentRecordID1];
for ( Page_View__c updateCount: recDetails)
{
updateCount.Count__c = updateCount.Count__c++;
totalUpdate.add(updateCount);
}
update totalUpdate;
}
}
**I am Getting the Error: Visualforce Error
Help for this Page
System.NullPointerException: Attempt to de-reference a null object Error is in expression '{!TotalRecordUpdate}' in component in page viewingvisualforce: Class.DisplayPage.TotalRecordUpdate: line 20, column 1 Class.DisplayPage.TotalRecordUpdate: line 20, column 1**
How to Rectify the Error anyone Guide Me