0

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?

javierpaniza
  • 677
  • 4
  • 10

1 Answers1

0

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;
javierpaniza
  • 677
  • 4
  • 10
  • Is there any way to use some kind of separator for the properties? There is only a single space separating them and depending on the data it gets confusing. To circumvent this I create a get method that concatenates things with my desired separator. Like `getNameSurname() { return UPPER(surname) + ", " + name; }` – Gustavo Mar 12 '23 at 19:23
  • No, separator is always a space. Using your own calculated property, like you have done, is a good workaround. – javierpaniza Mar 14 '23 at 12:42