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?
Asked
Active
Viewed 161 times
0
-
Please provide enough code so others can better understand or reproduce the problem. – Community Dec 23 '21 at 07:20
1 Answers
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");

javierpaniza
- 677
- 4
- 10