Could anybody tell me what I'm doing wrong? My code compiles just fine,
but I get a runtime exception saying that the Publisher class doesn't
have a publisher attribute. (Which is correct, it has a name and an id
attribute.) What should I change to make it get name from Publisher
instead? (Or get publisher from BookListData?)
Here's the HTML:
<html xmlns:wicket>
<wicket:panel>
<form wicket:id="filterform">
<table wicket:id="datatable">
</table>
</form>
</wicket:panel>
</html>
And here's the Java code:
BookListProvider booklistProvider = new BookListProvider();
AjaxFallbackDefaultDataTable<?> table = new
AjaxFallbackDefaultDataTable("datatable", createColumns(),
booklistProvider, 10);
FilterForm form = new FilterForm("filterform", booklistProvider);
table.addBottomToolbar(new FilterToolbar(table, form,
booklistProvider));
add(form);
form.add(table);
private IColumn<?>[] createColumns() {
IColumn<?>[] columns = new IColumn[6];
columns[0] = new PropertyColumn<String>(new
Model<String>("ISBN"), "isbn", "isbn");
columns[1] = new PropertyColumn<String>(new
Model<String>("Title"), "title", "title");
columns[2] = new PropertyColumn<ArrayList<Author>>(new
Model<String>("Author"), "authors");
columns[3] = new ChoiceFilteredPropertyColumn(new
Model<String>("Publisher"), "name", "publisher", createPublisherModel());
columns[4] = new PropertyColumn<Subgenre>(new
Model<String>("Subgenre"), "subgenre", "subgenre");
columns[5] = new PropertyColumn<Language>(new
Model<String>("Language"), "language", "language");
return columns;
}
private IModel<List<Publisher>> createPublisherModel() {
IModel<List<Publisher>> publisherModel = new
LoadableDetachableModel<List<Publisher>>() {
private static final long serialVersionUID = 1L;
@Override
protected List<Publisher> load() {
List<Publisher> publishers = null;
DataRetriever dataRetriever = null;
try {
dataRetriever = new DataRetriever();
publishers = dataRetriever.fetchPublishers();
} catch (Exception e) {
error("abbreviated error handling");
}
return publishers;
}
};
return publisherModel;
}
public class BookListProvider extends SortableDataProvider<BookListData>
implements IFilterStateLocator {
private final transient List<BookListData> list;
private Publisher publisherFilter = new Publisher();
...
}
Linda van der Pal wrote:
Are there any good examples out there that show how to use
ChoiceFilteredPropertyColumn and FilterToolbar? I've already looked at
wicket-phonebook, ut for some reason the FilterToolbar they use
doesn't require the FilterForm as an argument, whereas that is
required. They probably use an older version of Wicket, as I'm using
1.4-rc2.
Regards,
Linda
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org