SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 251 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

Most often, only the getOptions 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.tapestry.OptionGroupModel;
import org.apache.tapestry.OptionModel;
import org.apache.tapestry.util.AbstractSelectModel;
public class CelebritySelectModel extends AbstractSelectModel
{
private List celebrities;
public CelebritySelectModel(List celebrities)
{
this.celebrities = celebrities;
}
public List getOptionGroups()
{
return null;
}
public List getOptions()
{
List list = new ArrayList();
for (Celebrity c : celebrities)
{
list.add(new CelebrityOptionModel(c));
}
return list;
}
}
??? ???
Chapter 8
[ 209 ]
Again, almost nothing to comment on. We are passing a list of Celebrity objects
to display a constructor and then create another list, wrapping each celebrity into
CelebrityOptionModel.


Pages:
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6