title: JavaFX ListView edit TextFieldListCell
body: <p>I am working on a client-server solution and I have a ListView with my connected clients. The user should be able to remotely rename the clients just by editing the name in the ListView. I have read a lot about editing ListView cells, but I haven't found any good example where I can just change a member attribute of my class. Most of the examples are with a list of strings, and in my opinion this is not modern software development, if the items inside of the ListView are more than just strings.</p>
  <p><strong>What I want to do is to change the attribute <code>name</code> inside of my client.</strong></p>
  <pre><code>class Client {
      private String name;
      
      public String getName(){
          return name;
      }
      
      public String setName(String val){
          name = val;
      }
  }
  </code></pre>
  <p><em>I don't care, if I have to implement the member <code>name</code> as a JavaFX property (in fact I already have done that, but left it out for readability and simplicity).</em></p>
  <h2>Failed attempt to use the TextFieldListCell Factory</h2>
  <p>In case you are interested, I have tried to use the TextFieldListCell cell factory:</p>
  <pre><code>this.listViewClients.setCellFactory(TextFieldListCell
   .forListView(new NetworkClientStringConverter(this.clientController)));
  </code></pre>
  <p>But there are some tricky things i found out:</p>
  <ul>
  <li>Every time the name changes, I can't just access the object. Apparently what I am supposed to do is to create a new client and return it (<code>fromString</code>).
  <ul>
  <li>I solved this, by passing my client controller to the <code>StringConverter</code>. (This is not nice, I would prefer to just have access to the client I am changing.)</li>
  </ul>
  </li>
  <li>Still, the name does not change.</li>
  </ul>