You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Dylan Schell (JIRA)" <ji...@apache.org> on 2008/11/19 21:14:44 UTC
[jira] Updated: (WICKET-1939) ChoiceFilteredPropertyColumn forces
column type parameter and choice type parameter to be the same
[ https://issues.apache.org/jira/browse/WICKET-1939?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dylan Schell updated WICKET-1939:
---------------------------------
Attachment: ChoiceFilteredPropertyColumn.diff
these changes to ChoiceFilteredPropertyColumn seem to do the trick for me ( seperate type parameters column, and the filter choices )
> ChoiceFilteredPropertyColumn forces column type parameter and choice type parameter to be the same
> --------------------------------------------------------------------------------------------------
>
> Key: WICKET-1939
> URL: https://issues.apache.org/jira/browse/WICKET-1939
> Project: Wicket
> Issue Type: Bug
> Components: wicket-extensions
> Affects Versions: 1.4-RC1
> Reporter: Dylan Schell
> Priority: Minor
> Attachments: ChoiceFilteredPropertyColumn.diff
>
>
> ChoiceFilteredPropertyColumn takes one type parameter T this is also the type used in the filterChoices constructor parameter.
> since DefaultDataTable expects an array of IColumn<T> it is impossible to pass in a ChoiceFilteredPropertyColumn for a column type that is not itself T
> i.e.
> constructing a DefaultDataTable<Record>(....) expects all columns to be of type IColumn<Record>, and because of this, the list of choices in ChoiceFilteredPropertyColumn is of type IModel<List<? extends Record>
> non-compiling example:
> public class HomePage extends WebPage {
> private static final long serialVersionUID = 1L;
> /**
> * Constructor that is invoked when page is invoked without a session.
> *
> * @param parameters
> * Page parameters
> */
> public HomePage(final PageParameters parameters) {
> final List<Record> records = new ArrayList<Record>();
> for (int i = 0; i < 100; i++)
> records.add(new Record(i));
> List<IColumn<Record>> columns = new ArrayList<IColumn<Record>>();
> columns.add(new PropertyColumn<Record>(new Model<String>("Choice"), "choice"));
> IModel<List<String>> choiceModel = new AbstractReadOnlyModel<List<String>>() {
> public List<String> getObject() {
> return Arrays.asList("Choice 0", "Choice 1", "Choice 2");
> }
> };
> // WON'T COMPILE, since it expects IModel<List<? extends Record>
> // NOTE: a workaround is to declare the table as DefaultDataTable<?>
> // in that case it's possible to mix the different model types
> columns.add(new ChoiceFilteredPropertyColumn<Record>(new Model<String>("Choice 3"), "choice3", choiceModel));
> DefaultDataTable<Record> dataTable = new DefaultDataTable<Record>("dataTable", columns,
> new SortableListDataProvider<Record>(records), 20);
> add(dataTable);
> }
> public static class Record implements Serializable {
> public String choice;
> public Record(int id) {
> this.choice = "Choice +" + (id % 3);
> }
> }
> public static class SortableListDataProvider<T extends Serializable> extends ListDataProvider<T> implements
> ISortableDataProvider<T> {
> public SortableListDataProvider(List<T> list) {
> super(list);
> }
> public ISortState getSortState() {
> return null;
> }
> public void setSortState(ISortState state) {
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.