0

Hello thanks that code works very well; but in my case i want to display different time for example "07:00","08:00" and so on. is there a way for that to happen?

1 Answers1

0

To have a dropdown in OpenXava you can:

Define your property as a JPA @ManyToOne relationship annotated with @DescriptionsList.

@ManyToOne
@DescriptionsList
Hour hours;

You have an entity Hour that maps a table HOUR in your database, a combo box with all the value is shown.

Other option is to define a regular Java enum property:

public enum Color { UNSPECIFIED, RED, YELLOW, WHITE, BLACK }
Color color;

It will show a combo with the four values of the enum.

Finally, you can add the values programmatically, usind add/removeValidValue of View class.

For example, for a simple property like this:

String color;

You can add a combo programmatically in this way:

getView().addValidValue("color", "wht", "White");
getView().addValidValue("color", "blk", "Black");

Look at: https://openxava.org/OpenXavaDoc/docs/view_en.html#View-Property%20customization-Dynamic%20combos%20%28new%20in%20v5.8%29

javierpaniza
  • 677
  • 4
  • 10