org.apache.tapestry.form
Class EnumPropertySelectionModel

java.lang.Object
  extended by org.apache.tapestry.form.EnumPropertySelectionModel
All Implemented Interfaces:
IPropertySelectionModel

public class EnumPropertySelectionModel
extends Object
implements IPropertySelectionModel

Implementation of a property model that works off of native java enum types.

The enum label/values are all translated by calling Enum.toString() on your individual enum types, so it may be a good idea to provide a toString() method in your Enums if the types aren't what you would prefer to display.


Constructor Summary
EnumPropertySelectionModel(Enum[] set)
           
 
Method Summary
 String getLabel(int index)
          Returns the label for an option.
 Object getOption(int index)
          Returns one possible option that will be assigned to the server-side property.
 int getOptionCount()
          Returns the number of possible options.
 String getValue(int index)
          Returns a String used to represent the option in the HTML (as the value of an <option> or <input type=radio>.
 boolean isDisabled(int index)
          Used to help rendering of options that should be marked with the html disabled attribute.
 Object translateValue(String value)
          Returns the option corresponding to a value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumPropertySelectionModel

public EnumPropertySelectionModel(Enum[] set)
Method Detail

getLabel

public String getLabel(int index)
Returns the label for an option. It is the responsibility of the adaptor to make this value localized.

Specified by:
getLabel in interface IPropertySelectionModel

getOption

public Object getOption(int index)
Returns one possible option that will be assigned to the server-side property.

Specified by:
getOption in interface IPropertySelectionModel

getOptionCount

public int getOptionCount()
Returns the number of possible options.

Specified by:
getOptionCount in interface IPropertySelectionModel

getValue

public String getValue(int index)
Returns a String used to represent the option in the HTML (as the value of an <option> or <input type=radio>. This value is not visible to the user, and is often an index into an array.

Specified by:
getValue in interface IPropertySelectionModel

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)
Returns the option corresponding to a value. This is used when interpreting submitted form parameters.

Specified by:
translateValue in interface IPropertySelectionModel


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