A
download StringPropertySelectionModel.java
Language: Java
LOC: 31
Project Info
Tapestry: Java Web Components(tapestry)
Server: SourceForge
Type: cvs
...k\src\net\sf\tapestry\form\
   AbstractFormComponent.java
   AbstractTextField.java
   Button.java
   Button.jwc
   Checkbox.java
   Checkbox.jwc
   DatePicker.html
   DatePicker.java
   DatePicker.js
   DatePicker.jwc
   DatePicker.script
   ...ertySelectionModel.java
   Form.java
   Form.jwc
   FormEventType.java
   Hidden.java
   Hidden.jwc
   IFormComponent.java
   ImageSubmit.java
   ImageSubmit.jwc
   ...ertySelectionModel.java
   ...ySelectionRenderer.java
   ListEdit.java
   ListEdit.jwc
   Option.java
   Option.jwc
   package.html
   PropertySelection.java
   PropertySelection.jwc
   Radio.java
   Radio.jwc
   RadioGroup.java
   RadioGroup.jwc
   ...ySelectionRenderer.java
   Select.java
   Select.jwc
   ...ySelectionRenderer.java
   ...ertySelectionModel.java
   Submit.java
   Submit.jwc
   TextArea.java
   TextArea.jwc
   TextField.java
   TextField.jwc
   Upload.java
   Upload.jwc

package net.sf.tapestry.form;

/**
 *  Implementation of {@link IPropertySelectionModel} that allows one String from
 *  an array of Strings to be selected as the property.
 *
 *  <p>Uses a simple index number as the value (used to represent the selected String).
 *  This assumes that the possible values for the Strings will remain constant between
 *  request cycles.
 *
 *  @version $Id: StringPropertySelectionModel.java,v 1.5 2002/11/27 17:58:47 hship Exp $
 *  @author Howard Lewis Ship
 * 
 **/

public class StringPropertySelectionModel implements IPropertySelectionModel
{
    private String[] options;

    /**
     * Standard constructor.
     *
     * The options are retained (not copied).
     **/

    public StringPropertySelectionModel(String[] options)
    {
        this.options = options;
    }

    public int getOptionCount()
    {
        return options.length;
    }

    public Object getOption(int index)
    {
        return options[index];
    }

    /**
     *  Labels match options.
     *
     **/

    public String getLabel(int index)
    {
        return options[index];
    }

    /**
     *  Values are indexes into the array of options.
     *
     **/

    public String getValue(int index)
    {
        return Integer.toString(index);
    }

    public Object translateValue(String value)
    {
        int index;

        index = Integer.parseInt(value);

        return options[index];
    }

}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us