<html>
<body>
<div wicket:id="wmc">
</div>
Update list
</body>
</html>
public class MyPage extends WebPage {
UserDao dao = new UserDao();
private WebMarkupContainer wmc;
private IModel<List<User>> userListModel = new LoadableDetachableModel<List<User>>() {
@Override
public List<User> load() {
List<User> userList = dao.getUsers();
return userList;
}
};
public MyPage(String id) {
super(id);
wmc = new WebMarkupContainer("wmc");
wmc.setOutputMarkupId(true);
add(wmc);
ListView listView = new ListView("listView", userListModel) {
@Override
protected void populateItem(ListItem item) {
User user = (User) item.getModelObject();
item.add(new Label("name", user.getName()));
item.add(new Label("email", user.getEmail());
}
};
listView.setOutputMarkupId(true);
wmc.add(listView);
add(new AjaxFallbackLink("updateWmcLink") {
@Override
public void onClick(AjaxRequestTarget target) {
if (target != null) {
target.add(wmc);
}
}
});
}
}
public class User {
private String name;
private String email;
public User {
}
public Long getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}