| wicket.markup.html.WebMarkupContainer wicket.markup.html.list.ListView
All known Subclasses: wicket.examples.displaytag.utils.SimpleListView, wicket.markup.html.list.PropertyListView, wicket.markup.MyTable, wicket.examples.displaytag.utils.ListViewWithAlternatingRowStyle, wicket.markup.html.list.PageableListView,
ListView | abstract public class ListView extends WebMarkupContainer (Code) | | 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.
author: Jonathan Locke author: Juergen Donnerstag author: Johan Compagner author: Eelco Hillenius |
Method Summary | |
final public 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. | public boolean | getOptimizeItemRemoval() 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).
But if you modify the listView model object, than you must manually call
listView.removeAll() in order to rebuild the ListItems. | public 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).
But if you modify the listView model object, than you must manually call
listView.removeAll() in order to rebuild the ListItems. | final public int | getStartIndex() Get index of first cell in page. | public 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() | final public Link | moveDownLink(String id, ListItem item) Returns a link that will move the given item "down" (towards the end) in
the listView. | final public Link | moveUpLink(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) | abstract protected void | populateItem(ListItem item) Populate a given item.
be carefull to add any components to the list item. | final public Link | removeLink(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. | public Component | setList(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.
Parameters: list - The list for the new model. | public 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. | public ListView | setOptimizeItemRemoval(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).
But if you modify the listView model object, than you must manually call
listView.removeAll() in order to rebuild the ListItems. | public 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).
But if you modify the listView model object, than you must manually call
listView.removeAll() in order to rebuild the ListItems. | public ListView | setStartIndex(int startIndex) | public ListView | setViewSize(int size) Define the maximum number of items to render. |
getList | final public List getList()(Code) | | Gets the list of items in the listView. This method is final because it
is not designed to be overridden. If it were allowed to be overridden,
the values returned by getModelObject() and getList() might not coincide.
The list of items in this list view. |
getListItemModel | protected IModel getListItemModel(IModel listViewModel, int index)(Code) | | Subclasses may provide their own ListItemModel with extended
functionality. The default ListItemModel works fine with mostly static
lists where index remains valid. In cases where the underlying list
changes a lot (many users using the application), it may not longer be
appropriate. In that case your own ListItemModel implementation should
use an id (e.g. the database' record id) to identify and load the list
item model object.
Parameters: listViewModel - The ListView's model Parameters: index - The list item index The ListItemModel created |
getOptimizeItemRemoval | public boolean getOptimizeItemRemoval()(Code) | | 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).
But if you modify the listView model object, than you must manually call
listView.removeAll() in order to rebuild the ListItems. If you nest a
ListView in a Form, ALLWAYS set this property to true, as otherwise
validation will not work properly.
Whether to reuse itemsListView.getReuseItems() |
getReuseItems | public boolean getReuseItems()(Code) | | 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).
But if you modify the listView model object, than you must manually call
listView.removeAll() in order to rebuild the ListItems. If you nest a
ListView in a Form, ALLWAYS set this property to true, as otherwise
validation will not work properly.
Whether to reuse items |
getStartIndex | final public int getStartIndex()(Code) | | Get index of first cell in page. Default is: 0.
Index of first cell in page. Default is: 0 |
getViewSize | public int getViewSize()(Code) | | Based on the model object's list size, firstIndex and view size,
determine what the view size really will be. E.g. default for viewSize is
Integer.MAX_VALUE, if not set via setViewSize(). If the underlying list
has 10 elements, the value returned by getViewSize() will be 10 if
startIndex = 0.
The number of items to be populated and rendered. |
moveDownLink | final public Link moveDownLink(String id, ListItem item)(Code) | | Returns a link that will move the given item "down" (towards the end) in
the listView.
Parameters: id - Name of move-down link component to create Parameters: item - The link component |
moveUpLink | final public Link moveUpLink(String id, ListItem item)(Code) | | Returns a link that will move the given item "up" (towards the beginning)
in the listView.
Parameters: id - Name of move-up link component to create Parameters: item - The link component |
newItem | protected ListItem newItem(int index)(Code) | | Create a new ListItem for list item at index.
Parameters: index - ListItem |
onBeginPopulateItem | protected void onBeginPopulateItem(ListItem item)(Code) | | 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().
Parameters: item - |
populateItem | abstract protected void populateItem(ListItem item)(Code) | | Populate a given 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"));
Parameters: item - The item to populate |
removeLink | final public Link removeLink(String id, ListItem item)(Code) | | Returns a link that will remove this ListItem from the ListView that
holds it.
Parameters: id - Name of remove link component to create Parameters: item - The link component |
renderItem | protected void renderItem(ListItem item)(Code) | | Render a single item.
Parameters: item - The item to be rendered |
setList | public Component setList(List list)(Code) | | Sets the model as the provided list and removes all children, so that the
next render will be using the contents of the model.
Parameters: list - The list for the new model. The list must implementSerializable. This for chaining |
setOptimizeItemRemoval | public ListView setOptimizeItemRemoval(boolean reuseItems)(Code) | | 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).
But if you modify the listView model object, than you must manually call
listView.removeAll() in order to rebuild the ListItems. If you nest a
ListView in a Form, ALLWAYS set this property to true, as otherwise
validation will not work properly.
Parameters: reuseItems - Whether to reuse items thisListView.setReuseItems(boolean) |
setReuseItems | public ListView setReuseItems(boolean reuseItems)(Code) | | 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).
But if you modify the listView model object, than you must manually call
listView.removeAll() in order to rebuild the ListItems. If you nest a
ListView in a Form, ALLWAYS set this property to true, as otherwise
validation will not work properly.
Parameters: reuseItems - Whether to reuse the child items. this |
setStartIndex | public ListView setStartIndex(int startIndex)(Code) | | Set the index of the first item to render
Parameters: startIndex - First index of model object's list to display This |
setViewSize | public ListView setViewSize(int size)(Code) | | Define the maximum number of items to render. Default: render all.
Parameters: size - Number of items to display This |
|
|