I'm looking for the best way to implement a drop-down, where the type of the
model property is not the type of the lists:

For example, with the model below, I want to implement a drop-down to select
languages for a user.

    class User {
        String languageId;
    }

    class Language {
        String languageId;
        String languageName;
    }

    // From MyForm extends Form<User>
    // here, this.getModelObject returns a User
    // Somewhere in the constructor...
    ...
    List<Language> languages = getLanguagesFromDatabase();
    form.add (new DropDownChoice("languageDropDown", ...eh...?
    ...

My workaround involves creating a separate model for the language, and copy
from the language model to the user model whenever I use the user model. But
it's cumbersome...

1) Is there a better way?
2) Is there an established "best practice" for this (probaly common)
scenario?


Eirik

Reply via email to