|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wicketstuff.minis.util.collection.AbstractDetachableCollection<T>
T - public abstract class AbstractDetachableCollection<T>
A collection that can be coverted between attached and detached state via
calls to attach() and detach(). Elements are converted
between the two states using the specified IDetachCodec.
This collection allows the use of real objects, and yet has the convinience
of a small session footprint.
If the collection is detached, invocation of any method from
Collection will cause this collection to be attached.
NOTICE: During the conversion to either state N method calls are invoked on
the IDetachCodec, one for each element in the collection. This can
cause a performance problem in certain situations.
Example
class SelectUsersPanel extends Panel {
// codec to transcode user object to and from its detached state
private static final IDetachCodec<User> userCodec=new IDetachCodec<User> {
public Serializable detach(User object) { return object.getId(); }
public User attach(Serializable object) { return UserDao.get().userForId(object); }
}
// collection used to store selected user objects
private final DetachableHashSet<User> selected=new DetachableHashSet<User>(userCodec);
protected void onDetach() {
// this will shrink the size of selected collection before the page is stored in session.
// the collection will be attached automatically when some method is invoked on it.
selected.detach();
super.onDetach();
}
public SelectUsersPanel (String id) {
super(id);
Form form=new Form("form");
add(form);
CheckGroup checked=new CheckGroup("checked", new PropertyModel(this, "selected"));
form.add(checked);
checked.add(new DataView("users", new UsersDataProvider()) {
protected void populateItem(Item item) {
item.add(new Check("user", item.getModel()));
item.add(new Label("username", new PropertyModel(item.getModel(), "username")));
}
}
...
}
| Constructor Summary | |
|---|---|
AbstractDetachableCollection(IDetachCodec<T> codec)
Constructor |
|
| Method Summary | |
|---|---|
void |
attach()
Converts the collection into its attached state. |
void |
detach()
Converts the collection into a detached state. |
boolean |
equals(java.lang.Object obj)
|
protected java.util.Collection<T> |
getAttachedStore()
Returns collection used to store elements in attached state. |
int |
hashCode()
|
protected abstract java.util.Collection<T> |
newAttachedStore()
Creates a collection used to store elements in attached state |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Constructor Detail |
|---|
public AbstractDetachableCollection(IDetachCodec<T> codec)
codec - codec that will be used to transcode elements between attached
and detached states| Method Detail |
|---|
public final void attach()
public final void detach()
detach in interface org.apache.wicket.model.IDetachableprotected java.util.Collection<T> getAttachedStore()
protected abstract java.util.Collection<T> newAttachedStore()
public int hashCode()
hashCode in interface java.util.Collection<T>hashCode in class java.lang.ObjectObject.hashCode()public boolean equals(java.lang.Object obj)
equals in interface java.util.Collection<T>equals in class java.lang.ObjectObject.equals(java.lang.Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||