I want to count the number of times an output link has been clicked,and populate that value to a custom field,How can we achieve that? My code is as follows:

Visualforce page:

<apex:page controller="NoteExtension" showHeader="false" sidebar="false">

<apex:form >
    <apex:pageblock id="Note" title="Notes & Attachments" >

        <apex:pageBlockTable value="{!lstAttachment}" var="a" >

            <apex:column headerValue="Action">
                  <apex:outputLink value="/servlet/servlet.FileDownload?file={!a.Id}">View</apex:outputLink>
                  <apex:outputLink value="/servlet/servlet.FileDownload?file={!a.Id}">Download</apex:outputLink>
                  <apex:outputLink value="/{!a.Id}">Edit</apex:outputLink>
            <apex:column headerValue="Name">
                  <apex:outputField value="{!a.Name}"/>

                <apex:pageblockTable value="{!lstNote}" var="b">
                      <apex:column headerValue="Action">
                              <apex:outputLink value="/{!b.Id}">View</apex:outputLink>
                              <apex:outputLink value="/{!b.Id}">Download</apex:outputLink>
                              <apex:outputLink value="/{!b.Id}">Edit</apex:outputLink>
                      <apex:column headerValue="Title">
                              <apex:outputField value="{!b.Title}"/>

         <apex:pageBlockButtons location="top">
               <apex:commandButton value="New Note"/>
               <apex:commandButton value="Attach File"/>
               <apex:commandButton value="View All" />


Controller class:

public with sharing class NoteExtension{

       public List<Attachment> lstAttachment{ get; set; }
       public List<Note> lstNote{ get; set; }

    public NoteExtension(){
        lstNote= [Select isPrivate,Title,Body from Note where parentId=:apexpages.currentpage().getparameters().get('id') ];
        lstAttachment=[Select isPrivate,Name,Body from Attachment where parentId=:apexpages.currentpage().getparameters().get('id') ];


| improve this question | | | | |
  • can't you use onClick event for this outputLink? – Novarg Jun 22 '16 at 8:07
  • Yes I can add ,but then would the "value" attribute will work as expected? – Shobhit Saxena Jun 22 '16 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.