This is where we are going to create the model itself. The easiest way to do this is to extend the AbstractSelectModel
class that comes with Tapestry. In this case we shall need to implement just two methods, and one of them will always return null
.
List<OptionModel> getOptions()
—returns a list of options to display, using an implementation ofOptionModel
such as the one created above.List<OptionGroupModel> getOptionGroups()
—used to display grouped options. Most often, only thegetOptions
method is used, and so this one should return null. And reversely, if what we want to display is a list of grouped options, the first method should return null while this one will do the job.
Here is how the class that works with Celebrity objects might look (please add it to the com.packtpub.celebrities.util
package):
package com.packtpub.celebrities.util; import com.packtpub.celebrities.model.Celebrity; import java.util.ArrayList; import java.util.List; import org.apache...