org.trails.component
Class EnumPropertySelectionModel

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

public class EnumPropertySelectionModel
extends AbstractPropertySelectionModel

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

The main diference with Tapestry's EnumPropertySelectionModel is that "allowNone" and the property used to get the label values (labelProperty) are both configurable.

The enum label/values are all translated by calling the method indicated by "labelProperty" By default labelProperty = "toString()", 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.


Field Summary
 
Fields inherited from class org.trails.component.AbstractPropertySelectionModel
allowNone, DEFAULT_NONE_LABEL, DEFAULT_NONE_VALUE, instances, labelProperty, noneLabel
 
Constructor Summary
EnumPropertySelectionModel(java.lang.Class type)
           
EnumPropertySelectionModel(java.lang.Class type, boolean allowNone)
           
EnumPropertySelectionModel(java.lang.Class type, java.lang.String labelProperty, boolean allowNone)
           
EnumPropertySelectionModel(java.lang.Enum[] set)
           
EnumPropertySelectionModel(java.lang.Enum[] set, boolean allowNone)
           
EnumPropertySelectionModel(java.util.List instances, boolean allowNone)
           
 
Method Summary
 java.lang.String getValue(int index)
           
 java.lang.Object translateValue(java.lang.String value)
           
 
Methods inherited from class org.trails.component.AbstractPropertySelectionModel
getLabel, getLabelProperty, getNoneLabel, getOption, getOptionCount, isDisabled, setLabelProperty, setNoneLabel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumPropertySelectionModel

public EnumPropertySelectionModel(java.lang.Class type)

EnumPropertySelectionModel

public EnumPropertySelectionModel(java.lang.Enum[] set)

EnumPropertySelectionModel

public EnumPropertySelectionModel(java.lang.Enum[] set,
                                  boolean allowNone)

EnumPropertySelectionModel

public EnumPropertySelectionModel(java.util.List instances,
                                  boolean allowNone)

EnumPropertySelectionModel

public EnumPropertySelectionModel(java.lang.Class type,
                                  boolean allowNone)

EnumPropertySelectionModel

public EnumPropertySelectionModel(java.lang.Class type,
                                  java.lang.String labelProperty,
                                  boolean allowNone)
Method Detail

getValue

public java.lang.String getValue(int index)

translateValue

public java.lang.Object translateValue(java.lang.String value)


Copyright © 2004-2008. All Rights Reserved.