Hello together, how can show a list of properties which is inside of a bean.
For Example here are my two (simplified) beans:
@Entity
public class Customer {
@Id
private Long idCustomer;
...
@OneToMany(mappedBy = "customer", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
private List<CustomerAddress> customerAddresses;
...
}
@Entity
public class CustomerAddress {
@Id
private Long idCustomerAddress;
...
@ManyToOne
@JoinColumn(name = "ID_CUSTOMER")
private Customer customer;
...
}
I started with a BeanItemContainer wrapped with a GeneratedPropertyContainer. I created some more columns with the desired properties. But i think a GeneratedPropertyContainer is very difficult to handle. it doesn’t take the Type of the BeanItemContainer very well. I have to cast all the time. There are also some missing methods like “addAll” and some missing filter methods. But the biggest problem ist, that the properties are read only. Why is that designed like that? Why not additionaly if you create a PropertyValueGenerator, there is also a “setValue” method? The bad thing is so i have to remove and add the column for update. But thats very bad and it flickers.
So i also tried this with a BeanItemContainer and "addNestedContainerBean(“customerAddresses”). There is no error but there are also no columns for that. I think this is okay, because the container doesn’t know which address to show. But isn’t there a propertyformatter or something like that, which i can say that i want to show the first item of the list.
So how can i do that or should i select my components that it fits my bean classes?
Create two grids and if i select my customer i have a second grid which shows the addresses?