The ListView component is abstract, and has abstract method
populateItem. Thus you are forced to implement that method, which is
hopefully a clear indication that it does the work for you. Method
populateItem is called for every item in the list that you provide (or
actually, the list that is provided by the ListItem's IModel
instance). The method is called with an instance of ListItem, which is
the row container, and which holds an IModel instance (created for
you) that points to the current row of the list.
If you want to compare Wicket and Tapestry, comparive code looks like
this (I ommitted the Tapestry configuration code and Java code as I
don't know how to do that of the top of my head).
Tapestry without the Java code:
<tr jwcid="@For" source="ognl:customerList" value="ognl:customer"
element="tr">
<td><span jwcid="@Insert" value="ognl:customer.id"/></td>
<td><span jwcid="@Insert" value="ognl:customer.fullName"/></td>
<td><span jwcid="@Insert" value="ognl:customer.memberLevel"/></td>
</tr>
Wicket:
<tr wicket:id="customerList">
<td><span wicket:id="id"/></td>
<td><span wicket:id="fullName"/></td>
<td><span wicket:id="memberLevel"/></td>
</tr>
(java)
add(new ListView("customerList") {
protected void populateItem(ListItem item) {
Customer c = (Customer)item.getModelObject();
item.add(new Label("id", c.getId());
item.add(new Label("id", c.getFullName());
item.add(new Label("id", c.getMemberLevel());
}
}
Wicket code in the above example is more lines, but as I said I
omitted the Tapestry config and java.
I read that you dislike the use of annonymous classes. That's highly
personal; I actually like the use of annonymous classes like above,
though I usually have a seperate static private or public seperate
class for it for effeciency and easier reuse.
Have fun with your article.
Eelco
On 1/19/06, Gregg D Bolinger <[EMAIL PROTECTED]> wrote:
> Actually no, it doesn't make much more since. And yes, it's probably
> because I don't understand Wicket that well. What is confusing is...
> add(......) {
> @Override protected void populateItem(ListItem<Person> row)
> {
> Person person=row.getModelObject();
> row.add(new Label("firstName", person.getFirstName());
> ...
> }
> }
>
> So how would you create a ListView and then add it to the page (not all at
> once). That would make more since. At least to me. :) If I said anything
> that downplayed Wicket in my article, it wasn't on purpose. I tried to say
> most of my issues were my own lack of understanding. I like Wicket. I am
> still just trying to determine if it is something I want to invest time in
> and use.
>
> Thanks for the help.
>
> Gregg
>
>
>
>
>
> On 1/18/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > by the way Gregg, your post is a little unfair. sure it is hard to
> understand whats going on if youve never seen wicket before because there is
> some casting involved. consider the same example if generics were used (yes
> currently not supported)
> >
> > add(new ListView<Person>("people", getPeople())
> > {
> > @Override protected void populateItem(ListItem<Person> row)
> > {
> > Person person=row.getModelObject();
> > row.add(new Label("firstName", person.getFirstName());
> > ...
> > }
> > }
> >
> > is that easier to understand at a first glance if you dont know wicket? i
> think so.
> >
> > -Igor
> >
> >
> >
> >
> > On 1/18/06, Igor Vaynberg <[EMAIL PROTECTED] > wrote:
> > > the model is a locator for the underlying value object, so what it
> really affords you is a level of indirection.
> > >
> > > take a simple read only example. the use of the model allows the
> underlying value object to change dynamically w/out the component knowing or
> worrying about it.
> > >
> > > so for example new Label("id", "hello world") is nice. but its value
> object ("hello world") is static and doesnt change.
> > >
> > > now suppose you want that value to change, lets say the label represents
> a page property and you want it to update automatically w/out having to
> worry about it. so now you can create a model to pull the value from the
> page property.
> > >
> > > new Label("id", new PropertyModel(this, "hello"));
> > >
> > > now everytime the label renders it will ask its model for the value
> object, which in turn calls getHello() on the page. and now the label always
> displays whatever is in the hello property of the page w/out any tweaking.
> > >
> > > so as i said, its a very nice level of indirection that can contain any
> amount of logic. you can achieve some very cool behaviors due to this, but i
> dont have time to go into them right now. recently on the list i showed one
> of these here:
> > >
> > >
> http://thread.gmane.org/gmane.comp.java.wicket.user/7469
> > >
> > > if you are intereseted.
> > >
> > > hope this explains some of it, im short on time :(
> > >
> > > -Igor
> > >
> > >
> > >
> > >
> > > On 1/18/06, Gregg D Bolinger < [EMAIL PROTECTED] > wrote:
> > > > I blogged about it recently but I wondered if anyone had any other
> documentation that explains when one should use which IModel implementation?
> Anything other than browsing through all the example code? Thanks.
> > > >
> > > > Gregg
> > > >
> > >
> > >
> >
> >
>
>
-------------------------------------------------------
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?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user