<html> <body> <div wicket:id="wmc">
Name | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 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< void >( "updateWmcLink" ) { @Override public void onClick(AjaxRequestTarget target) { if (target != null ) { target.add(wmc); } } }); } } </ void > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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; } } |