0

how can we create the dropdown list type question in OpenXava? Let's say Gender is the question with (Male, Female, Other) with respective answers.

How can I declare the variable in the POJO class. Or do we have any hibernate annotations for the same.

Please suggest.

Vinod
  • 2,263
  • 9
  • 55
  • 104

1 Answers1

1

Define your property as an enum, thus:

private Sex sex;
public enum Sex { MALE, FEMALE, OTHER }

OpenXava will generate a combo for that.

javierpaniza
  • 677
  • 4
  • 10
  • Yes, It is working as expected and I am able to save the data in database. But While searching OR editing an existing record I am getting an system error (java.lang.IllegalArgumentException:Unknown name value for enum class, com.test.dashboard.model.Sex), Why? How to resolve this? – Vinod Jan 12 '15 at 12:18
  • Hi Precious, put the complete code of you class and the stacktrace produced in the Tomcat log in the OpenXava Help forum: https://sourceforge.net/p/openxava/discussion/419690/ – javierpaniza Jan 13 '15 at 13:01
  • @javierpaniza What will be persisted in database for a enum? A varchar like 'FEMALE' ? – Gustavo Mar 12 '23 at 19:32
  • The way an enum is stored in database is not OpenXava specific, but a JPA issue. Look at: https://stackoverflow.com/questions/38252617/storing-enum-values-with-jpa – javierpaniza Mar 14 '23 at 12:41