I have a select dropdown in a Tapestry form that is populated by objects through a SelectModelFactory. I am currently displaying the first name of the object to the client but I would like to display both the first name and the last name and I'm having a devil of a time figuring out how to add another labelProperty. My model is created per the below code:
List<Person> persons = personFinderService.findPersons();
personsModel = selectModelFactory.create(persons, "firstName");
I've tried several things:
(persons, "firstName" + "lastName")
(persons, "firstName" & "lastName")
(persons, "firstName" && "lastName")
(persons, "firstName + lastName")
(persons, "firstName & lastName")
(persons, "firstName && lastName")
(persons, "firstName", "lastName")
But I can't get both names to display. Any help would be much appreciated. Tapestry isn't much used so there isn't a lot of online support.
You could either create a new method in your Person
class:
public class Person {
...
public String getFullName() {
return firstName + " " + lastName;
}
}
and then personsModel = selectModelFactory.create(persons, "fullName");
.
Or work with internal SelectModelImpl
and OptionModelImpl
directly.