org.barracudamvc.contrib.dbroggisch.repopulation
Class SelectFormElement

java.lang.Object
  extended byorg.barracudamvc.core.forms.DefaultFormElement
      extended byorg.barracudamvc.contrib.dbroggisch.repopulation.SelectFormElement
All Implemented Interfaces:
Comparable, FormElement, RepopulationElement
Direct Known Subclasses:
GroupFormElement

public class SelectFormElement
extends DefaultFormElement
implements RepopulationElement

Use this FormElement to repopulate the request value into a select box created by the <select>-tag.

Version:
1.0
Author:
Diez B. Roggisch

Field Summary
 
Fields inherited from class org.barracudamvc.core.forms.DefaultFormElement
allowMultiples, defaultVal, format, key, name, origVal, parent, pe, type, val, validator
 
Constructor Summary
SelectFormElement(ListModel lm, ListSelectionModel lsm, String ikey, FormType itype, Object idefaultVal, FormValidator ivalidator)
          Creates a new SelectFormElement instance.
SelectFormElement(ListModel lm, ListSelectionModel lsm, String ikey, String iname, FormType itype, Object idefaultVal, FormValidator ivalidator, boolean iallowMultiples)
          Creates a new SelectFormElement instance.
SelectFormElement(ListModel lm, String ikey, FormType itype, Object idefaultVal, FormValidator ivalidator, boolean iallowMultiples)
          Creates a new SelectFormElement instance.
SelectFormElement(ListModel lm, String ikey, String iname, FormType itype, Object idefaultVal, FormValidator ivalidator, boolean iallowMultiples)
          Creates a new SelectFormElement instance.
SelectFormElement(String ikey, FormType itype, Object idefaultVal, FormValidator ivalidator)
          Creates a new SelectFormElement instance.
SelectFormElement(String ikey, String iname, FormType itype, Object idefaultVal, FormValidator ivalidator, boolean iallowMultiples)
          Creates a new SelectFormElement instance.
 
Method Summary
static ListSelectionModel calcListSelectionModel(List vals, List sel, int selType)
          A convenience method that takes two lists, the latter beeing a subset of the first, and computes the ListSelectionModel for them.
static int calcSelectionMode(List vals, List sel)
          This is a helper method that takes a list of permitted values, and a subset of selected values out of the former list.
static int calcSelectionMode(ListSelectionModel lsm)
          This method computes the actual mode for the given ListSelectionModel.
 ListModel getListModel()
          Get the list of allowed values.
 ListSelectionModel getListSelectionModel()
          Get the ListSelectionModel.
 Object render(ViewContext context)
          Describe render method here.
 void setListModel(ListModel lm)
          Set the list of allowed values.
 void setListSelectionModel(ListSelectionModel lsm)
          Set the ListSelectionModel that determines which entries of the select box are rendered.
 
Methods inherited from class org.barracudamvc.core.forms.DefaultFormElement
allowMultiples, compareTo, getDefaultVal, getFormat, getKey, getName, getOrigVal, getParentForm, getParseException, getType, getVal, getVal, getValidator, getVals, getVals, setAllowMultiples, setDefaultVal, setFormat, setKey, setName, setOrigVal, setParentForm, setParseException, setType, setVal, setValidator, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectFormElement

public SelectFormElement(String ikey,
                         String iname,
                         FormType itype,
                         Object idefaultVal,
                         FormValidator ivalidator,
                         boolean iallowMultiples)
Creates a new SelectFormElement instance.

Parameters:
ikey - a java.lang.String value
iname - a java.lang.String value
itype - a FormType value
idefaultVal - a java.lang.Object value
ivalidator - a FormValidator value
iallowMultiples - a boolean value

SelectFormElement

public SelectFormElement(ListModel lm,
                         String ikey,
                         String iname,
                         FormType itype,
                         Object idefaultVal,
                         FormValidator ivalidator,
                         boolean iallowMultiples)
Creates a new SelectFormElement instance.

Parameters:
lm - a ListModel value
ikey - a java.lang.String value
iname - a java.lang.String value
itype - a FormType value
idefaultVal - a java.lang.Object value
ivalidator - a FormValidator value
iallowMultiples - a boolean value

SelectFormElement

public SelectFormElement(ListModel lm,
                         String ikey,
                         FormType itype,
                         Object idefaultVal,
                         FormValidator ivalidator,
                         boolean iallowMultiples)
Creates a new SelectFormElement instance.

Parameters:
lm - a ListModel value
ikey - a java.lang.String value
itype - a FormType value
idefaultVal - a java.lang.Object value
ivalidator - a FormValidator value
iallowMultiples - a boolean value

SelectFormElement

public SelectFormElement(ListModel lm,
                         ListSelectionModel lsm,
                         String ikey,
                         String iname,
                         FormType itype,
                         Object idefaultVal,
                         FormValidator ivalidator,
                         boolean iallowMultiples)
Creates a new SelectFormElement instance.

Parameters:
lm - a ListModel value
lsm - a ListSelectionModel value
ikey - a java.lang.String value
iname - a java.lang.String value
itype - a FormType value
idefaultVal - a java.lang.Object value
ivalidator - a FormValidator value
iallowMultiples - a boolean value

SelectFormElement

public SelectFormElement(String ikey,
                         FormType itype,
                         Object idefaultVal,
                         FormValidator ivalidator)
Creates a new SelectFormElement instance.

Parameters:
ikey - a java.lang.String value
itype - a FormType value
idefaultVal - a java.lang.Object value
ivalidator - a FormValidator value

SelectFormElement

public SelectFormElement(ListModel lm,
                         ListSelectionModel lsm,
                         String ikey,
                         FormType itype,
                         Object idefaultVal,
                         FormValidator ivalidator)
Creates a new SelectFormElement instance.

Parameters:
lm - a ListModel value
lsm - a ListSelectionModel value
ikey - a java.lang.String value
itype - a FormType value
idefaultVal - a java.lang.Object value
ivalidator - a FormValidator value
Method Detail

setListModel

public void setListModel(ListModel lm)
Set the list of allowed values.

Parameters:
lm - a ListModel value

getListModel

public ListModel getListModel()
Get the list of allowed values.

Returns:
a ListModel value

setListSelectionModel

public void setListSelectionModel(ListSelectionModel lsm)
Set the ListSelectionModel that determines which entries of the select box are rendered.

Parameters:
lsm - a ListSelectionModel value

getListSelectionModel

public ListSelectionModel getListSelectionModel()
Get the ListSelectionModel.

Returns:
a ListSelectionModel value

calcSelectionMode

public static int calcSelectionMode(List vals,
                                    List sel)
This is a helper method that takes a list of permitted values, and a subset of selected values out of the former list. It will then compute the mode that fits this selection. See ListSelectionModel.

Parameters:
vals - a List of permitted values
sel - a List which specifies a subset of vals
Returns:
the mode, as specified in ListSelectionModel

calcSelectionMode

public static int calcSelectionMode(ListSelectionModel lsm)
This method computes the actual mode for the given ListSelectionModel. See ListSelectionModel for the range of permitted values.

Parameters:
lsm - a ListSelectionModel value
Returns:
an int value

calcListSelectionModel

public static ListSelectionModel calcListSelectionModel(List vals,
                                                        List sel,
                                                        int selType)
A convenience method that takes two lists, the latter beeing a subset of the first, and computes the ListSelectionModel for them.

Parameters:
vals - a List value
sel - a List value
selType - see ListSelectionModel for the range of permitted values
Returns:
a ListSelectionModel value

render

public Object render(ViewContext context)
Describe render method here.

Specified by:
render in interface RepopulationElement
Parameters:
context - a ViewContext value
Returns:
an Object value


Copyright © 2004 BarracudaMVC.org All Rights Reserved.