|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry.form.ListEditMap
public class ListEditMap
A utility class often used with the ListEdit
component. A
ListEditMap is loaded with data objects before the ListEdit renders, and again before the
ListEdit rewinds. This streamlines the synchronization of the form against data on the server. It
is most useful when the set of objects is of a manageable size (say, no more than a few hundred
objects).
The map stores a list of keys, and relates each key to a value. It also tracks a deleted flag for each key.
Usage:
The page or component should implement PageRenderListener
and
implement
PageRenderListener.pageBeginRender(org.apache.tapestry.event.PageEvent)
to initialize the map.
The external data (from which keys and values are obtained) is queried, and each key/value pair
is added
to the map, in the order that items should be presented.
The ListEdit
's source parameter should be bound to the map's
keys
property. The value parameter should be bound to the map's
key
property.
The ListEdit
's listener parameter should be bound to a listener
method to synchronize a property of the component from the map.
public void synchronize(IRequestCycle
cycle)
{
ListEditMap map = ...;
<i>Type</i> object = (<i>Type</i>)map.getValue();
if (object == null)
...
set<i>Property</i>(object);
}
You may also connect a Checkbox
's selected parameter to the
map's deleted
property.
You may track inclusion in other sets by subclasses and implementing new boolean properties. The
accessor method should be a call to checkSet(Set)
and the mutator method should be a
call to updateSet(Set, boolean)
.
Constructor Summary | |
---|---|
ListEditMap()
|
Method Summary | |
---|---|
void |
add(Object key,
Object value)
Records the key and value into this map. |
protected boolean |
checkSet(Set set)
Returns true if the set contains the current key . |
protected List |
convertSetToList(Set set)
|
List |
getAllValues()
Returns all the values stored in the map, in the order in which values were added to the map using add(Object, Object) . |
List |
getDeletedKeys()
Returns the deleted keys in an unspecified order. |
Object |
getKey()
Returns the current key within the map. |
List |
getKeys()
Returns a List of keys, in the order that keys were added to the map (using add(Object, Object) . |
Object |
getValue()
Returns the value for the key (set using setKey(Object) ). |
List |
getValues()
Returns all the values stored in the map, excluding those whose id has been marked deleted, in the order in which values were added to the map using add(Object, Object) . |
boolean |
isDeleted()
Returns true if the current key is in the set of deleted keys. |
void |
setDeleted(boolean value)
Adds or removes the current key from the set of deleted keys. |
void |
setKey(Object key)
Sets the key for the map. |
protected Set |
updateSet(Set set,
boolean value)
Updates the set, adding or removing the current key from it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ListEditMap()
Method Detail |
---|
public void add(Object key, Object value)
getKeys()
. This also sets the current key (so that you may invoke
setDeleted(boolean)
, for example).
public List getKeys()
add(Object, Object)
. The caller must not modify the List.
public void setKey(Object key)
getValue()
,isDeleted()
,setDeleted(boolean)
.
public Object getKey()
public Object getValue()
setKey(Object)
). May return null if no
such key has been added (this can occur if a data object is deleted between the time a form
is rendered and the time a form is submitted).
public boolean isDeleted()
current key
is in the set of deleted keys.
protected boolean checkSet(Set set)
current key
. Returns false is the set
is null, or doesn't contain the current key.
public void setDeleted(boolean value)
current key
from the set of deleted keys.
protected Set updateSet(Set set, boolean value)
current key
from it. Returns the
set passed in. If the value is true and the set is null, an new instance of HashSet
is created and returned.
public List getDeletedKeys()
protected List convertSetToList(Set set)
public List getAllValues()
add(Object, Object)
.
public List getValues()
add(Object, Object)
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |