|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry.form.EnumPropertySelectionModel
public class EnumPropertySelectionModel
Implementation of IPropertySelectionModel
that wraps around
a set of Enum
s.
Uses a simple index number as the value (used to represent the option).
The resource bundle from which labels are extracted is usually
a resource within the Tapestry application. Since
ResourceBundle.getBundle(String, java.util.Locale)
uses its caller's class loader,
and that classloader will be the Tapestry framework's classloader, the application's
resources won't be visible. This requires that the application resolve
the resource to a ResourceBundle
before creating this model.
Constructor Summary | |
---|---|
EnumPropertySelectionModel(org.apache.commons.lang.enum.Enum[] options,
ResourceBundle bundle)
Simplified constructor using no prefix. |
|
EnumPropertySelectionModel(org.apache.commons.lang.enum.Enum[] options,
ResourceBundle bundle,
String resourcePrefix)
Standard constructor. |
Method Summary | |
---|---|
String |
getLabel(int index)
Returns the label for an option. |
Object |
getOption(int index)
Returns one possible option. |
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>. |
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 |
---|
public EnumPropertySelectionModel(org.apache.commons.lang.enum.Enum[] options, ResourceBundle bundle, String resourcePrefix)
Labels for the options are extracted from a resource bundle. resourceBaseName
identifies the bundle. Typically, the bundle will be a .properties
file within the classpath. Specify the fully qualified class name equivalent, i.e.,
for file /com/example/foo/LabelStrings.properties
use
com.example.foo.LabelStrings
as the resource base name.
Normally (when resourcePrefix is null), the keys used to extract labels
matches the enumeration id
of the option. By
convention, the enumeration id matches the name of the static variable.
To avoid naming conflicts when using a single resource bundle for multiple models, use a resource prefix. This is a string which is prepended to the enumeration id (they prefix and enumeration id are seperated with a period).
options
- The list of possible values for this model, in the order they
should appear. This exact array is retained (not copied).bundle
- The ResourceBundle
from which labels may be extracted.resourcePrefix
- An optional prefix used when accessing keys within the bundle.
Used to allow a single ResouceBundle to contain labels for multiple Enums.public EnumPropertySelectionModel(org.apache.commons.lang.enum.Enum[] options, ResourceBundle bundle)
Method Detail |
---|
public int getOptionCount()
IPropertySelectionModel
getOptionCount
in interface IPropertySelectionModel
public Object getOption(int index)
IPropertySelectionModel
getOption
in interface IPropertySelectionModel
public String getLabel(int index)
IPropertySelectionModel
getLabel
in interface IPropertySelectionModel
public String getValue(int index)
IPropertySelectionModel
getValue
in interface IPropertySelectionModel
public Object translateValue(String value)
IPropertySelectionModel
translateValue
in interface IPropertySelectionModel
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |