| |
| |
| Component @org.apache.wicket.markup.repeater.RepeatingView@ is a container which renders its children components using the tag it is bound to. It can contain an arbitrary number of children elements and we can obtain a new valid id for a new child calling its method newChildId(). This component is particularly suited when we have to repeat a simple markup fragment, for example when we want to display some items as a HTML list: |
| |
| *HTML:* |
| {code:html} |
| <ul> |
| <li wicket:id="listItems"></li> |
| </ul> |
| {code} |
| |
| *Java Code:* |
| {code} |
| RepeatingView listItems = new RepeatingView("listItems"); |
| |
| listItems.add(new Label(listItems.newChildId(), "green")); |
| listItems.add(new Label(listItems.newChildId(), "blue")); |
| listItems.add(new Label(listItems.newChildId(), "red")); |
| {code} |
| |
| *Generated markup:* |
| {code:html} |
| <ul> |
| <li>green</li> |
| <li>blue</li> |
| <li>red</li> |
| </ul> |
| {code} |
| |
| As we can see in this example, each child component has been rendered using the parent markup as if it was its own. |