title: How to change tableelement by toggle listener
body: <p>I have a primefaces 11 project. On my site ther is a datatable with some elemets of a custom class of mine. One attribute is an active flag which is represented by a toggleswitch in my table. If you want to change any attribute of a record you have to use the changebutton which works just fine. But I thought it would be easier if you could toggle the activation on the fly. So I made a toggleswitch with an ajax-listener. The table looks like this:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;p:dataTable id=&quot;dt-queries&quot; widgetVar=&quot;dtQueries&quot; reflow=&quot;true&quot;
    showGridlines=&quot;true&quot; size=&quot;small&quot; var=&quot;querie&quot;
    value=&quot;#{abfrageHandler.abfragen}&quot; rowKey=&quot;#{querie.pk}&quot; &gt;
    &lt;p:column headerText=&quot;Abfrage&quot;&gt;
      &lt;h:outputText value=&quot;#{querie.name}&quot; /&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText=&quot;Zyklus&quot;&gt;
      &lt;h:outputText value=&quot;#{querie.zyklus.displayName}&quot; /&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText=&quot;Typ&quot;&gt;
      &lt;h:outputText value=&quot;#{querie.typ.displayName}&quot; /&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText=&quot;System&quot;&gt;
      &lt;h:outputText value=&quot;#{querie.refSystem}&quot; /&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText=&quot;Aktiv&quot;&gt;
      &lt;p:toggleSwitch id=&quot;active&quot; value=&quot;#{querie.active}&quot; &gt;
        &lt;p:ajax listener=&quot;#{abfrageHandler.toggleActive}&quot;/&gt;
      &lt;/p:toggleSwitch&gt;
    &lt;/p:column&gt;
    &lt;p:column exportable=&quot;false&quot;&gt;
      &lt;p:commandButton icon=&quot;pi pi-search&quot;
        actionListener=&quot;#{abfrageHandler.startAbfrage(querie)}&quot;
        styleClass=&quot;edit-button rounded-button ui-button-success&quot;
        process=&quot;@this&quot;&gt;
      &lt;/p:commandButton&gt;
  
      &lt;p:commandButton icon=&quot;pi pi-pencil&quot;
        update=&quot;abfrageForm:manage-queries-content&quot;
        oncomplete=&quot;PF('manageQueriesDialog').show()&quot;
        styleClass=&quot;edit-button rounded-button ui-button-success&quot;
        process=&quot;@this&quot;&gt;
        &lt;f:setPropertyActionListener value=&quot;#{querie}&quot;
          target=&quot;#{abfrageHandler.selected}&quot; /&gt;
        &lt;p:resetInput target=&quot;abfrageForm:manage-queries-content&quot; /&gt;
      &lt;/p:commandButton&gt;
  
      &lt;p:commandButton class=&quot;ui-button-warning rounded-button&quot;
        icon=&quot;pi pi-trash&quot; process=&quot;@this&quot;
        oncomplete=&quot;PF('deleteQuerieDialog').show()&quot;&gt;
        &lt;f:setPropertyActionListener value=&quot;#{querie}&quot;
          target=&quot;#{abfrageHandler.selected}&quot; /&gt;
      &lt;/p:commandButton&gt;
    &lt;/p:column&gt;
  &lt;/p:dataTable&gt;
  </code></pre>
  <p>At the moment my toggleActive-methode looks like this:</p>
  <pre class="lang-java prettyprint-override"><code>public void toggleActive(AjaxBehaviorEvent event) {
    System.out.println(&quot;Funktion called&quot;);
    Object a = event.getSource();
    a.toString();
  }
  </code></pre>
  <p>I had issues with the event type because none of the primefacesevents worked, the function was never called by a ToggleEvent nor an AbstractAjaxBehaviorEvent. In the event I can see somewhat happend, but I can't identify for whom it happend so I'm not able to persist the change directly.</p>
  <p>Could you please help me how to identify the current record?</p>