How to concatenate 2 fields to show in a combo for a @ManyToOne reference with @DescriptionsList in OpenXava?

116 Views Asked by At

The @ManyToOne relationship in OpenXava, only allows me to lookup a table in a combo box from another table for a description attribute (one field only). For example, if I write:

@DescriptionsList
@ManyToOne
Product product

I get a combo box with the description field of all products.

My plan is to take two fields like firstName and surName then concatenate them as a string into the description filed for the look-up

How do I join the two fields in the @DescriptionsList combo?

1

There are 1 best solutions below

2
javierpaniza On

The descriptionProperties attribute of @DescriptionsList allows you to specify several properties separated by commas, so you can write:

@ManyToOne
@DescriptionsList(descriptionProperties="firstName, surName")
private Customer customer;