THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
Code Block |
---|
class MyPage extends WebPage { private String criteria; //getter/setter for criteria public MyPage() { {panel} IModel listModel=new LoadableDetachableModel() { Object load() { UserService service=...get user service; List users=service.findUsersFiltered(criteria); return users; } }; add(new ListView("users", listModel) {....}); {panel} |
so here we have the listview that will show a list that is filtered on
page's criteria property. now we hookup our dropdownchoice in such a way
that it modifies this property and when the page refreshes so will the
listview because it is using a detachble model.
Code Block |
---|
Form form=new Form(); add(form); List filters=new ArrayList(); filters.add("a"); filters.add("b"); form.add(new DropDownChoice("filter", new PropertyModel(this, "criteria"), filters) { wantOnChangeNotifiactionwantOnChangeNotification() { return true; }); // here we glue dropdown choice to our criteria property via the property model }} |
and thats it. to overview what we have done:
...