Reputation: 3512
Maybe it's an easy question, but I'm new to wicket and after googling for some time I can't find the answer.
Let's assume I have a div, a container, where I store some data.
<div id="container">
[here goes data]
</div>
Now I connect to a database where I have some number (we dont know how many) messages to display with a date. The thing is I want the cointainer to be popullated with yet another divs for example:
<div id="container">
<div id="first-message>
<span>15.11.2011</span>
<span>A message</span>
</div>
<div id="second-message>
<span>14.11.2011</span>
<span>A message</span>
</div>
<div id="third-message>
<span>13.11.2011</span>
<span>A message</span>
</div>
...and so on...
</div>
Is it possible? Where should I look for answer? One think that upsets me is lack of good support for wicket newbies :/
Upvotes: 0
Views: 678
Reputation: 10380
What you want to use is a subclass of AbstractRepeater
. Have a look at ListView
and its javadoc for a start. A repeater repeats its markup multiple times. Your html would look like this:
<div id="container">
<div wicket:id="repeater">
<span wicket:id="date">15.11.2011</span>
<span wicket:id="message">A message</span>
</div>
</div>
In Java, the repeater would be added with the id repeater
. Each repeater child item would contain both date
and message
labels
.
Some reference material for you:
https://cwiki.apache.org/WICKET/listview-and-other-repeaters.html
http://wicket.apache.org/learn/examples/guestbook.html
Upvotes: 3
Reputation: 3583
you could use ListView take a look at https://cwiki.apache.org/WICKET/listview-and-other-repeaters.html for support you can also see at http://wicketstuff.org/wicket/index.html
Upvotes: 2