Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The most common repeater is wicket.ListView, but there are also a number of components in the wicket-extensions' repeaters package.

FAQ

Q1. I added behavior (for example a SimpleAttributeModifier) to the ListView but I do not see its results in the output. Why?
Q2. I called ListView#setRenderBodyOnly(falsetrue) but the enclosing tags are still generated. How come?
Q3. My validation messages are cleared. What did I do?

...

A quick introduction

Code:

Code Block
    List list = Arrays.asList(new String[] { "a", "b", "c" });
    ListView listview = new ListView("listview", list) {
        protected void populateItem(ListItem item) {
            item.add(new Label("label", item.getModel()));
        }
    }};
add(listview);

Markup:

Code Block
<span wicket:id="listview">
   this label is: <span wicket:id="label">label</span><br/>
</span>

...

Using form components in a repeater

Note

Due to the dynamic nature of such repeaters as ListView, RefreshingView, and DataView you may want to use a less dynamic repeater such as RepeatingView to build your form. However, if you do need a really dynamic form where rows come and go on the fly then see below...

You can put anything in the repeater, including FormComponents. You can bind values to the form components through IModels just as if they were in a regular form.

...

The variable userList is initialized as follows:

Code Block
  List listuserList = Arrays.asList(
    new User[] {
        new User("FirstA", "LastA"),
        new User("FirstB", "LastB"),
        new User("FirstC", "LastC")
      });

...

Code Block
class User {
    String _first, _last;

    public User(String _first, String _last) {
        this._first = _first;
        this._last = _last;
    }

    public String getFirstname() { return _first; }
    public String getLastname() { return _last; }
}

Accessing the cell/row index:

Code Block

protected void populateItem(ListItem item) {
	// cell index
	item.getIndex();

	// row index
	((Item)item.getParent().getParent()).getIndex();
}

Optimizing the example with PropertyListView

...