net.sf.tacos.model
Class BeanPropertySelectionModel

java.lang.Object
  extended by net.sf.tacos.model.BeanPropertySelectionModel
All Implemented Interfaces:
Serializable, org.apache.tapestry.form.IPropertySelectionModel

public class BeanPropertySelectionModel
extends Object
implements org.apache.tapestry.form.IPropertySelectionModel, Serializable

This class is a property selection model for an object list. This is used in PropertySelection, MultiplePropertySelection or Palette tapestry components. For example, to use for a Hospital class, and have the labels be the hospital names. List<Hospital> list = ...; return new BeanPropertySelectionModel(hospitals, "name"); This will use getName() on the Hospital object, as its display.

Author:
Gabriel Handford
See Also:
Serialized Form

Constructor Summary
BeanPropertySelectionModel()
          Build an empty property selection model.
BeanPropertySelectionModel(Collection c, String labelField)
          Build a bean property selection model.
BeanPropertySelectionModel(List list, String labelField)
          Build a bean property selection model.
 
Method Summary
 String getLabel(int index)
          Get the label at index.
 Object getOption(int index)
          Get the option at index.
 int getOptionCount()
          Get the number of options.
 String getValue(int index)
          Get the value at index.
 Object translateValue(String value)
          Translate value to object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanPropertySelectionModel

public BeanPropertySelectionModel()
Build an empty property selection model.


BeanPropertySelectionModel

public BeanPropertySelectionModel(List list,
                                  String labelField)
Build a bean property selection model.

Parameters:
list - The list
labelField - The label field

BeanPropertySelectionModel

public BeanPropertySelectionModel(Collection c,
                                  String labelField)
Build a bean property selection model.

Parameters:
c - Collection
labelField - The label field
Method Detail

getOptionCount

public int getOptionCount()
Get the number of options.

Specified by:
getOptionCount in interface org.apache.tapestry.form.IPropertySelectionModel
Returns:
option count

getOption

public Object getOption(int index)
Get the option at index.

Specified by:
getOption in interface org.apache.tapestry.form.IPropertySelectionModel
Parameters:
index - Index
Returns:
object Object at index

getLabel

public String getLabel(int index)
Get the label at index.

Specified by:
getLabel in interface org.apache.tapestry.form.IPropertySelectionModel
Parameters:
index - Index
Returns:
label Label at index

getValue

public String getValue(int index)
Get the value at index.

Specified by:
getValue in interface org.apache.tapestry.form.IPropertySelectionModel
Parameters:
index - Index
Returns:
value Value at index

translateValue

public Object translateValue(String value)
Translate value to object.

Specified by:
translateValue in interface org.apache.tapestry.form.IPropertySelectionModel
Parameters:
value - Value
Returns:
object Object from value