function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chanti kchanti k 

same user clicked multipulle times on button that time i don't want increment count value i need only one time count.

HI Experts 

This is my reuirement.

i have Follow button. for ex: i want count  avalue only one time but here same user clicked multipulle times on button that time i don't want increment count value. please help me how to i will write a logic in method.

 
<apex:commandButton id="CommandButton1" value="Follow" action="{!followOwner}"/>



public Integer followingCount{get;set;}

//Constructor
public userData (ApexPages.StandardController stdController) {
    UserId = UserInfo.getUserId();
    GetCount();
}

 //Method
 public void GetCount() {

 List<User> following = [SELECT Id, Name,title, SmallPhotoUrl FROM User WHERE Id =:parentsetid AND Id !=:u.id order by name]; 
    followingCount = following.size();
 }


Thanks in Advance,
Chanti
 
WEN JIEWEN JIE
You can add some check after first click or hide the button after first click by rendered and reRender.
ashishashish
Hi,
Here is what you can do to achieve this:

/***Apex Class Controller****/
public  Class Test{
    
    public integer count{get;set;}
    private boolean b;
    
    public Test(){
        Count=0;
        b=true;
    }
    
    public void  proceed(){
        ID id=Userinfo.getUserid();
        if(b==true)
            getcount();
    }
    
    public Void getcount(){
        count=count+1;
        b=false;
    }

}


/****Vf Page*****/
 <apex:page controller="Test">
    <apex:form >
        <apex:pageBlock title="Hello!">
        <apex:pageBlockSection >
            <apex:outputText  value="{!Count}" / >
         </apex:pageBlockSection> 
         <apex:pageBlockButtons >  
          <apex:commandButton Value="Proceed" Action="{!Proceed}" />
         </apex:pageBlockButtons>

        </apex:pageBlock>

    </apex:form>

</apex:page>

on clicking 'Proceed button' it will increment this count only once for current User

Thanks
please mark this answer best if it solves your problem.
Satish PrajapatSatish Prajapat
//Visualforce Page
<apex:pageblock id="BloackID" rendered="{!blockVisibility}" >
      <apex:commandButton id="CommandButton1" value="Follow" action="{!followOwner}"/>
</apex:pageblock>



//Apex:
public Class Test
{
     public String blockVisibility {get; set;}
     public Test()
     {
          blockVisibility = true;
     }
     public void CountMethod()
     {
           count++;
           blockVisibility = false;
     }
}

Hi Chanti k,
Please find the code above it may be help you.
if it help you please select it as a best answer.
Thanks, 
Enjoy Development.