package net.sf.tapestry.form;
/**
* Used by a {@link PropertySelection} to provide labels for options.
*
* <p>The component requires three different representations
* of each option:
* <ul>
* <li>The option value, a Java object that will eventually be assigned to
* a property
* <li>The label, a String which is incorprated into the HTML to identify the
* option to the user
* <li>The value, a String which is used to represent the option as the value
* of the <option> or <input type=radio> generated by the
* {@link PropertySelection}.
* </ul>
*
* <p>The option is usually either an {@link net.sf.tapestry.util.Enum}
* (see {@link EnumPropertySelectionModel})
* or some kind of business object. The label is often a property of the
* option object (for example, for a list of customers, it could be the customer name).
*
* <p>It should be easy to convert between the value and the option. It may simply
* be an index into an array. For business objects, it is often the primary key
* of the object, expressed as a String.
*
* @version $Id: IPropertySelectionModel.java,v 1.4 2002/11/27 17:58:47 hship Exp $
* @author Howard Lewis Ship
*
**/
public interface IPropertySelectionModel
{
/**
* Returns the number of possible options.
*
**/
public int getOptionCount();
/**
* Returns one possible option.
*
**/
public Object getOption(int index);
/**
* Returns the label for an option. It is the responsibility of the
* adaptor to make this value localized.
*
**/
public String getLabel(int index);
/**
* Returns a String used to represent the option in the HTML (as the
* value of an <option> or <input type=radio>.
*
**/
public String getValue(int index);
/**
* Returns the option corresponding to a value. This is used when
* interpreting submitted form parameters.
*
**/
public Object translateValue(String value);
}