Refresh nested property in Grid

Hi,

I have two Grids and two JPAContainers (address, transaction). Transaction has nested @ManyToOne Address.

There’s and issue with updating nested column

address

in

transactionGrid



, when the address was edited in addresGrid.

When I try to edit address in addresGrid in editor mode:

addressGrid.setEditorEnabled(true); Addres column which is rendered as
address.toString()
in transactionGrid won’t update even on

transactionContainer.refresh(); or

for(Object transactionIdWithEditedAddress : allTransactionsWithEditedAddress) transactionContainer.refreshItem(transactionIdWithEditedAddress); I’ve tried to evict the cache, but it didn’t help.

The only effective idea I came up with was to add a new address on edit in adresContainer and update all the transactions in transactionContainer with the new address.

addressGrid.getEditorFieldGroup().addCommitHandler(new CommitHandler() { public void postCommit(CommitEvent commitEvent) throws CommitException { Item i = commitEvent.getFieldBinder().getItemDataSource(); Address a = new Address(i); for(Object tId: transactionsWithEditedAddress) { transactionContainer.getItem(tId).getEntity().setAdres(a); } and then

transactionContainer.refresh();


Is there a more convenient way?

Two beans:

@Entity public class Transaction { ... @ManyToOne(fetch = FetchType.EAGER) @NotNull @JoinColumn(name = ADDRESS_ID, referencedColumnName = Address.ID, foreignKey = @ForeignKey(name = Address.ID) ) @JoinFetch(JoinFetchType.INNER) @Index private Address address; ... } and

@Entity public class Address { ... @Index @Column(name=NAME) private String name; @Index @Column(name=LASTNAME) private String lastName; ... @Override public final String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(name); buffer.append(" "); buffer.append(lastName); buffer.append(" "); buffer.append(company); buffer.append("\n"); buffer.append(street); buffer.append("\n"); buffer.append(postCode); buffer.append(" "); buffer.append(city); return buffer.toString(); } and two JPA containers connected with two Grids (one for editing transactions and one for addresses):

  private JPAContainer<Transaction> transactionContainer = JPAContainerFactory.make(Transaction.class, JPA);
  private JPAContainer<Address> addressContainer = JPAContainerFactory.make(Address.class, JPA);
...
  GeneratedPropertyContainer gpct = new GeneratedPropertyContainer(transactionContainer);
  transactionGrid.setContainerDataSource(gpct);

  GeneratedPropertyContainer gpca = new GeneratedPropertyContainer(addressContainer);
  addressGrid.setContainerDataSource(gpca);

Best Regards,
Andrzej Marcinkowski