Skip to content

Categories:

A PropertyModel, Label and a list

Just a quick tip that I didn’t realise I could do , if say you can an Entity:

public class Person {
String name;
List emails;
}

public class Email {
String email;
}

Say for whatever reason I only want to show the first email in the list you can do the following using a CompoundPropertyModel :

...
setModel(new CompoundPropertyModel
(person);
add(new Label("name"));
add(new Label("email", new PropertyModel(item.getModel(), "emails[0].email")));

Notice the syntax for the PropertyModel and how you get directly index the list:

emails[0].email

. Wicket is smart enough to take care of nulls, which is why wicket is wicked.

Share and Enjoy:
  • Digg
  • Print this article!
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Slashdot

Posted in general. Tagged with .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.