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
Janno RipJanno Rip 

Method updates all records inside <list> - should update only 1

I have implemented the following visualforce page on the lead layout:
User-added image
Here is the code:
<apex:page standardController="Lead" extensions="JTo_LeadeventOnLead" tabStyle="Lead" showHeader="false" sidebar="false" >
    <style>
      
        .hmk_top5table{
         
            color:black;
            width:99%;

            font-family:Arial, Helvetica, sans-serif;
            font-size:12px;
            padding:5px;
    
            background:white; 
            margin:5px;
            border:rgb(50,205,50) 1px solid;
        
            -moz-border-radius:5px;
            -webkit-border-radius:5px;
            border-radius:5px; 
        }
         
    </style>
    <apex:form >
    <apex:pagemessages />
    <apex:outputPanel id="hmk_panel_top5table" rendered="{!the_le_list!=null && the_le_list.size>0 && (the_lead.Leadevents_in_Bearbeitung_Counter__c > 0 || the_lead.Nicht_zugewiesene_Leadevents_Counter__c > 0) }">
    
        <table class="hmk_top5table"> 
            <tr>
                <th style="text-align:center;padding:5px;">Aktion</th>
                <th style="text-align:center;padding:5px;">Leadevent</th>
                <th style="text-align:center;padding:5px;">Phase</th>
                <th style="text-align:center;padding:5px;">Datum</th>
                <th style="text-align:center;padding:5px;">Fälligkeitsdatum</th>
                <th style="text-align:center;padding:5px;">Ungeöffnet</th>
      
            </tr> 
 
            <apex:variable var="ct" value="{!1}"/>
            <apex:repeat value="{!the_le_list}" var="sega" >
                <tr style="display: {!IF(sega.isClosed__c = true,'none','table-row')};"   > 
                    
                    <td style="text-align:center">
                     

                       <apex:commandButton rendered="{!sega.Phase__c = 'Offen'}" disabled="{!sega.Leadevents_in_Bearbeitung_Counter_II__c > 0 && sega.Leadevents_nicht_zugewiesen_Counter__c > 0}" styleClass="btn" style="right:10px;position:relative;width:150px;" action="{!accept}" id="accept" value="Akzeptieren"/>
                       <apex:commandButton rendered="{!sega.Phase__c = 'Offen'}" styleClass="btn" style="width:150px;" action="{!decline}" id="decline" value="Ablehnen"/>
                       <apex:commandButton rendered="{!sega.Phase__c="in Bearbeitung" && sega.Leadevents_in_Bearbeitung_Counter_II__c > 0 && sega.Leadevents_nicht_zugewiesen_Counter__c > 0}" styleClass="btn" style="width:150px;" action="{!close}" id="close" value="Abschließen"/>

                   </td>


                    <td style="text-align:center">
                        <apex:outputLink style="color:{!IF(sega.Phase__c = 'in Bearbeitung','green','')}" target="_blank" value="{!URLFOR($Action.Leadevents__c.View, sega.Id, null)}">
                            <apex:outputtext value="{!sega.name}"/>
                        </apex:outputLink>          
                    </td>
                        
                     
                    <td style="text-align:center;color:{!IF(sega.Phase__c = 'in Bearbeitung','green','')}">
                        <apex:outputField value="{!sega.Phase__c}" /> 
                    </td>
                    
                   <td style="text-align:center">
                        <apex:outputText value="{0,date,dd.MM.yyyy}" >
                            <apex:param value="{!sega.Datum_des_Leadevents__c}"/> 
                        </apex:outputText>
                        
                    </td>
                                    
                    <td style="text-align:center;color:{!IF(sega.F_lligkeitsdatum__c < TODAY(),'red','')}">
                        <apex:outputText value="{0,date,dd.MM.yyyy}" >
                            <apex:param value="{!sega.F_lligkeitsdatum__c}"/> 
                        </apex:outputText>
                        
                    </td>
          
                    <td style="text-align:center">
                    
                    <apex:inputCheckBox value="{!sega.Unge_ffnet_JR__c}"/>
                    
                    </td>
                      
                </tr>
                <apex:variable var="ct" value="{!(ct+1)}"/>
            </apex:repeat>
        </table>        
        
    </apex:outputPanel>
</apex:form>
</apex:page>
Here is my code:
public with sharing class JTo_LeadeventOnLead {

    public Lead the_lead {get; private set;} 
    
    public Leadevents__c the_leadevent {get; private set;}
    
    public string the_leadid {get; private set;}
     
    public List<Leadevents__c> the_le_list {get; private set;}
    
    public JTo_LeadeventOnLead(ApexPages.StandardController standardController) {
        
        the_leadid = standardController.getId(); 
        
        the_lead = [
                    SELECT id, Name,Nicht_zugewiesene_Leadevents_Counter__c , Leadevents_in_Bearbeitung_Counter__c  
                    FROM Lead
                    WHERE id = : the_leadid
                    LIMIT 1
                  ];
   
        if(the_lead != null){
        
                the_le_list = [     
                                        SELECT Id, Name,F_lligkeitsdatum__c,Phase__c,Datum_des_Leadevents__c,Unge_ffnet_JR__c,isClosed__c,Leadevents_in_Bearbeitung_Counter_II__c,Leadevents_nicht_zugewiesen_Counter__c
                                        FROM Leadevents__c 
                                        WHERE Lead__c = : the_leadid
                                        Order by F_lligkeitsdatum__c DESC
                                        LIMIT 5
                                  ];
                                  
        the_leadevent = [ 
        
                                        SELECT Id, Name,F_lligkeitsdatum__c,Phase__c,Datum_des_Leadevents__c,Unge_ffnet_JR__c,isClosed__c,Leadevents_in_Bearbeitung_Counter_II__c,Leadevents_nicht_zugewiesen_Counter__c
                                        FROM Leadevents__c 
                                        WHERE Lead__c = : the_leadid
                                        LIMIT 1
                                    ];    
                                                                 

}
}


public PageReference accept() {

     
    for (Leadevents__c le : the_le_list) {
        le.Phase__c = 'in Bearbeitung';
    }
    
    update the_le_list;

    return null;
        
  }
}

What happens?
If I hit my custom commandbutton "accept" every entry in the list is getting updated and the visualforce page refreshes.
User-added image
What should happen?
Only the record where i hit the "Accept" - button should be updated and not only should the vf page refresh but the entire lead since I want the related lists - that include my custom object - to be up to date.
User-added image