Nella pagina

<apex:outputpanel id="counter">
       <apex:outputText value="Click Me!: {!count}"/>
       <apex:actionSupport event="onclick" 
                          action="{!incrementCounter}" 
                          rerender="counter" status="counterStatus"/>
</apex:outputpanel>

Nel controller

Integer count = 0;
                        
    public PageReference incrementCounter() {
            count++;
            return null;
    }
                    
    public Integer getCount() {
        return count;
    }