here is an unrolled listview example using the ordered repeating view from extensions. ORV is like a listview in respect that it lets its immediate children use its markup.

OrderedRepeatingView repeater=new OrderedRepeatingView("repeater");

for (int i=0;i<users.size();i++) {
  final User user=users.get(i);
  WebMarkupContainer item=new WebMarkupContainer(String.valueOf(i)); //1
  repeater.add(item); //2
  item.add(new Label("firstname", user.getFirstName())); //3
  item.add(new Label("lastname", user.getLastName())); //3
}

so in a listview
step 1: is the ListItem container created for you. notice that we use i counter as the unique child id because we cannot have id collissions. this is also taken care for you by the ListView.
step 2 is also take care for you by the listview
step 3 happens in your implementation of populateItem

-Igor



On 1/23/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
radiogroup aside

lets take a simple example, we want to show a table of users:

<table>
  <tr wicket:id="listview">
    <td><span wicket:id="firstname"/></td><td><span wicket:id="lastname"/></td>
  </tr>
</table>

what we want is everything within <tr>...</tr> to repeat once for every user. so we attach listview to the tr tag.

what listview does is make its immediate children believe that their markup is that of the listview itself. so each immediate child believes that it is attached to the <tr wicket:id="listview"> tag.

we need to represent these immediate listview children with a container component, because each of these children may contain multiple children of its own, in our case the firstname/lastname labels. this is what the listitem is, its a simple WebMarkupContainer created for you so you dont have to do it everytime youself.

so we will have a listitem container created for every list item in the list that feeds the lisview. but this is not enough. each of these listitems must contain the components that represent data within it (the firstname, lastname labels that we want to add).

this is where populateitem comes in, it is called once for every listitem created and allows you to add components to it.

so the listview render process looks like this:

before each render:
  clear all children
  for every list item in the list:
     create a ListItem webmarkupcontainer
     add created ListItem as a child
     call populateItem with the created ListItem container to allow users to populate it
render:
  render all immediate children with own markup

does this help or confuse you more?

-Igor



On 1/23/06, Frank Silbermann < [EMAIL PROTECTED]> wrote:
Has anyone written about the way ListView works in Wicket -- i.e. the
roles played by ListView, ListItem and the models belonging to these
components?
I've looked at the JavaDoc in the hope of gaining some intuition as to
what is going on, but I'm having "a difficult time seeing the forest
because of all the trees."

For example, I'm looking at the Component Reference examples,
specifically the RadioGroupPage.  The RadioGroup object is constructed
with "new Model()" -- which leads me to ask myself "What kind of a silly
model is that?

Looking at the API documentation for RadioGroup, is says that the
group's model is "set to the model of the selected Radio component."  So
I'm guessing that "new Model()" is just a filler to tell the RadioGroup
NOT to search for a ComponentModel further up the hierarchy -- this
time, the model comes from down lower in the hierarch.  (If that's true,
perhaps this usage of a trivial model ought to be described somewhere in
the RadioGroup JavaDoc.  Or is it a more general pattern followed by a
variety of selection components?  Does the JavaDoc for the most general
abstract selection component explain this usage?)

So I look further down for the Radio objects themselves, and see that
they are created within the populateItem() method of an anonymous
subclass of ListView.  Perhaps the relationship between RadioGroup and
Radio would be more easily understood via a simpler (though less
practical) example in which the set of Radio components were hardcoded
-- my vague understanding of working with Listview is getting in the
way.

As it stands, we give each Radio component the same model as one of the
ListItem components of the ListView.  I presume the ListItem is built
from one of the items of the java.util.List from which the ListView was
contructed -- but how???

I suppose my next step is to look at the Wicket implementation of
ListView and ListItem to figure out what is going on.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Reply via email to