BaseColumn should support setting/changing of nested properties

Issue #10 on hold
Former user created an issue

Instances of BaseColumn support nested properties when fetching data from the underlying pojo.

You can do something like the following:

final TextColumn<PlcConfParameter> valueColumn = new TextColumn<PlcConfParameter>("plcConfChannel.name");

I found the following in the tiwulfx sources, which determines wether the property should be handled as simple or nested property:

if (getPropertyName().contains(".")) {
    cellValue = PropertyUtils.getNestedProperty(param.getValue(), getPropertyName());
} else {
    cellValue = PropertyUtils.getSimpleProperty(param.getValue(), getPropertyName());
}

Everything is fine up to now! My Problem is that there is no distinction between simple and nested properties when changing and saving a value of such a nested property.

I would like to see something like the following in the TableControl class:

public void addColumn(TableColumn<T, ?>... columns) {
  //...
  if (column instanceof BaseColumn) {
    final BaseColumn baseColumn = (BaseColumn) column;
    //..
    baseColumn.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<T, ?>>() {
      @Override
      public void handle(CellEditEvent<T, ?> t) {
        if (baseColumn.getPropertyName().contains(".")) {
          PropertyUtils.setNestedProperty(persistentObj, baseColumn.getPropertyName(), t.getNewValue());
        } else {
          PropertyUtils.setSimpleProperty(persistentObj, baseColumn.getPropertyName(), t.getNewValue());
        }
      }
    }
  }
  //...
}

It would be very helpful to integrate that kind of nested property handling since I really like your work - awesome! Keep up this great FX library!

Regards,

Alex

(alexander.orbach@gmx.net)

Comments (3)

  1. Panemu Ind repo owner

    It is problematic. A nested column is basically a parent record from other table that is possibly referred by many rows. In that case, changing the value of nested column should refresh all rows displayed in TableControl that refer to that very same parent record.

    In my apps, I always disable editing of nested column. This issue is put on hold until developer team have more consideration to make the decision.

  2. Javlon Eraliyev

    @panemu Nested property can be also embedded property. Hibernate supports @Embeddable, @Embedded. So in table it is single entity, but in code they are root entity and it's nested entity.

  3. Log in to comment