|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwicket.Component
wicket.MarkupContainer
wicket.markup.html.WebMarkupContainer
wicket.markup.html.list.ListView
public abstract class ListView
A ListView holds ListItem children. Items can be re-ordered and deleted, either one at a time or many at a time.
Example:
<tbody>
<tr wicket:id="rows" class="even">
<td><span wicket:id="id">Test ID</span></td>
...
Though this example is about a HTML table, ListView is not at all limited to HTML tables. Any kind of list can be rendered using ListView.
The related Java code:
add(new ListView("rows", listData)
{
public void populateItem(final ListItem item)
{
final UserDetails user = (UserDetails)item.getModelObject();
item.add(new Label("id", user.getId()));
}
});
WARNING: though you can nest ListViews within Forms, you HAVE to set the
optimizeItemRemoval property to true in order to have validation work
properly. By default, optimizeItemRemoval is false, which has the effect that
ListView replaces all child components by new instances. The idea behind this
is that you always render the fresh data, and as people usually use ListViews
for displaying read-only lists (at least, that's what we think), this is good
default behavior.
However, as the components are replaced before the rendering starts, the
search for specific messages for these components fails as they are replaced
with other instances. Another problem is that 'wrong' user input is kept as
(temporary) instance data of the components. As these components are replaced
by new ones, your user will never see the wrong data when optimizeItemRemoval
is false.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class wicket.Component |
|---|
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor, Component.VisibilityChange |
| Field Summary |
|---|
| Fields inherited from class wicket.Component |
|---|
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER |
| Constructor Summary | |
|---|---|
ListView(java.lang.String id)
|
|
ListView(java.lang.String id,
IModel model)
|
|
ListView(java.lang.String id,
java.util.List list)
|
|
| Method Summary | |
|---|---|
java.util.List |
getList()
Gets the list of items in the listView. |
protected IModel |
getListItemModel(IModel listViewModel,
int index)
Subclasses may provide their own ListItemModel with extended functionality. |
boolean |
getOptimizeItemRemoval()
Deprecated. Use getReuseItems() instead |
boolean |
getReuseItems()
If true re-rendering the list view is more efficient if the windows doesn't get changed at all or if it gets scrolled (compared to paging). |
int |
getStartIndex()
Get index of first cell in page. |
int |
getViewSize()
Based on the model object's list size, firstIndex and view size, determine what the view size really will be. |
protected void |
internalOnAttach()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
Link |
moveDownLink(java.lang.String id,
ListItem item)
Returns a link that will move the given item "down" (towards the end) in the listView. |
Link |
moveUpLink(java.lang.String id,
ListItem item)
Returns a link that will move the given item "up" (towards the beginning) in the listView. |
protected ListItem |
newItem(int index)
Create a new ListItem for list item at index. |
protected void |
onBeginPopulateItem(ListItem item)
Comes handy for ready made ListView based components which must implement populateItem() but you don't want to lose compile time error checking reminding the user to implement abstract populateItem(). |
protected void |
onRender(MarkupStream markupStream)
Renders this component. |
protected abstract void |
populateItem(ListItem item)
Populate a given item. |
Link |
removeLink(java.lang.String id,
ListItem item)
Returns a link that will remove this ListItem from the ListView that holds it. |
protected void |
renderItem(ListItem item)
Render a single item. |
Component |
setList(java.util.List list)
Sets the model as the provided list and removes all children, so that the next render will be using the contents of the model. |
Component |
setModel(IModel model)
Sets the model and removes all current children, so that the next render will be using the contents of the model. |
ListView |
setOptimizeItemRemoval(boolean reuseItems)
Deprecated. Use setReuseItems(boolean) instead |
ListView |
setReuseItems(boolean reuseItems)
If true re-rendering the list view is more efficient if the windows doesn't get changed at all or if it gets scrolled (compared to paging). |
ListView |
setStartIndex(int startIndex)
Set the index of the first item to render |
ListView |
setViewSize(int size)
Define the maximum number of items to render. |
| Methods inherited from class wicket.markup.html.WebMarkupContainer |
|---|
getMarkupType, getWebPage |
| Methods inherited from class wicket.MarkupContainer |
|---|
add, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, internalAdd, internalAttach, internalDetach, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onComponentTagBody, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, size, toString, toString, visitChildren, visitChildren |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ListView(java.lang.String id)
Component.Component(String)
public ListView(java.lang.String id,
IModel model)
Component.Component(String, IModel)
public ListView(java.lang.String id,
java.util.List list)
id - See Componentlist - List to cast to SerializableComponent.Component(String, IModel)| Method Detail |
|---|
public final java.util.List getList()
public boolean getOptimizeItemRemoval()
getReuseItems() instead
public boolean getReuseItems()
public final int getStartIndex()
public int getViewSize()
public final Link moveDownLink(java.lang.String id,
ListItem item)
id - Name of move-down link component to createitem -
public final Link moveUpLink(java.lang.String id,
ListItem item)
id - Name of move-up link component to createitem -
public final Link removeLink(java.lang.String id,
ListItem item)
id - Name of remove link component to createitem -
public ListView setOptimizeItemRemoval(boolean reuseItems)
setReuseItems(boolean) instead
reuseItems - Whether to reuse items
public ListView setReuseItems(boolean reuseItems)
reuseItems - Whether to reuse the child items.
public ListView setStartIndex(int startIndex)
startIndex - First index of model object's list to display
public ListView setViewSize(int size)
size - Number of items to display
public Component setList(java.util.List list)
list - The list for the new model. The list must implement
Serializable.
public Component setModel(IModel model)
setModel in class MarkupContainermodel - The new model
MarkupContainer.setModel(wicket.model.IModel)
protected IModel getListItemModel(IModel listViewModel,
int index)
listViewModel - The ListView's modelindex - The list item index
protected void internalOnAttach()
Component
internalOnAttach in class ComponentComponent.internalOnAttach()protected ListItem newItem(int index)
index -
protected void onBeginPopulateItem(ListItem item)
item - protected void onRender(MarkupStream markupStream)
MarkupContainer
onRender in class MarkupContainerComponent.onRender(wicket.markup.MarkupStream)protected abstract void populateItem(ListItem item)
be carefull to add any components to the list item. So, don't do:
add(new Label("foo", "bar"));
but:
item.add(new Label("foo", "bar"));
item - The item to populateprotected void renderItem(ListItem item)
item - The item to be rendered
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||