com.tonbeller.wcf.list
Class MappedListBox

java.lang.Object
  extended bycom.tonbeller.wcf.list.MappedListBox
All Implemented Interfaces:
FormListener

public class MappedListBox
extends java.lang.Object
implements FormListener

THIS IS CRAP - DONT USE!

stateful listbox. initialize():

  Element parent = ...
  // erzeuge Listbox Element
  Element lb = ListBox1.addListBox1(parent);
  ListBox1.setId(lb, DomUtils.randomId());
    ListBox1.setLabel(lb, p.getLabel());

    // create MappedListBox
    MappedListBox mlb = new MappedListBox(lb);

    // add Items
    Object[] objs = ...
    for (int i = 0; i < objs.length; i++) {
      Object o = objs[i];
      MappedListBox.Item item = new MappedListBox.Item(hier.getLabel(), o);
      mlb.getEntries().add(item);
      if (some condition)
        item.setSelected(true);
    }
    mlb.sortByLabel();

    // create DOM Elements
    mlb.revert();
 
validate():
  mlb.validate(context);
    MappedListBox.Item item = mlb.getSingleSelection();
    if (item != null)
      ... // work with selection
 
revert():
   mlb.revert();
 

Author:
av

Nested Class Summary
static class MappedListBox.Item
          listbox entry
 
Constructor Summary
MappedListBox(org.w3c.dom.Element listBox)
           
 
Method Summary
 java.util.List getEntries()
          Returns the entries.
 MappedListBox.Item getSingleSelection()
           
 void revert(RequestContext context)
          reverts this component to model values
 void setEntries(java.util.List entries)
          Sets the entries.
 void sortByLabel()
           
 boolean validate(RequestContext context)
          validates user input and updates the model
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappedListBox

public MappedListBox(org.w3c.dom.Element listBox)
Method Detail

revert

public void revert(RequestContext context)
Description copied from interface: FormListener
reverts this component to model values

Specified by:
revert in interface FormListener

validate

public boolean validate(RequestContext context)
Description copied from interface: FormListener
validates user input and updates the model

Specified by:
validate in interface FormListener
Returns:
true if validation was successful

getSingleSelection

public MappedListBox.Item getSingleSelection()

sortByLabel

public void sortByLabel()

getEntries

public java.util.List getEntries()
Returns the entries.

Returns:
List

setEntries

public void setEntries(java.util.List entries)
Sets the entries.

Parameters:
entries - The entries to set