org.apache.tapestry.form
Class BeanPropertySelectionModel

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

public class BeanPropertySelectionModel
extends Object
implements 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

Field Summary
protected  String _labelField
           
protected  List _list
           
 
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
 boolean equals(Object o)
           
 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.
 int hashCode()
           
 boolean isDisabled(int index)
          Used to help rendering of options that should be marked with the html disabled attribute.
 String toString()
           
 Object translateValue(String value)
          Translate value to object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_list

protected List _list

_labelField

protected String _labelField
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 IPropertySelectionModel
Returns:
option count

getOption

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

Specified by:
getOption in interface 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 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 IPropertySelectionModel
Parameters:
index - Index
Returns:
value Value at index

isDisabled

public boolean isDisabled(int index)
Description copied from interface: IPropertySelectionModel
Used to help rendering of options that should be marked with the html disabled attribute.

Specified by:
isDisabled in interface IPropertySelectionModel
Parameters:
index - The option to check.
Returns:
True if the option shouldn't be selectable, false otherwise.

translateValue

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

Specified by:
translateValue in interface IPropertySelectionModel
Parameters:
value - Value
Returns:
object Object from value

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.