Hi I've quickly knocked up this [1]. It's in Scala, I started with Java but got frustrated with just how slow I was.
Note if you convert this to Java. You won't be able to use Java 8 Optional as it is not serializable (my biggest disappointment of java 8) so back to nullable model objects and lots of if (x != null ) boiler plate. I hope it helps. [1] https://gist.github.com/bollinger/433ec1b54167baf88297b495a5df0cff On 11 January 2017 at 10:38, Zbynek Vavros <[email protected]> wrote: > Hey, > > I have a DropDownChoice for list of users. I want to display user's name > but bind user's ID. > So far I have come to this (ugly) solution that can surely be improved: > > // create model with Long userId... > final DropDownChoice<Long> usersDropDown = new DropDownChoice<>( > "userId", Lists.transform(User.getUsers(), new > Function<User, Long>() { > @Nullable > @Override > public Long apply(@Nullable final User user) { > return user.getId(); > } > }), > new ChoiceRenderer<Long>() { > @Override > public Object getDisplayValue(final Long id) { > return User.findOne(id); > } > } > ); > > Thanks for any pointers. > Zbynek > -- Peter Henderson
