You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Linda van der Pal <lv...@heritageagenturen.nl> on 2009/04/29 11:55:32 UTC

ChoiceFilteredPropertyColumn and FilterToolbar examples

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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ChoiceFilteredPropertyColumn and FilterToolbar examples

Posted by Linda van der Pal <lv...@heritageagenturen.nl>.
Hmm, maybe I can phrase that question simpler. If I have a table that 
shows BookListItems, which have a Publisher as one of their attributes 
and I want to be able to filter on the publisher, what should be passed 
on to the ChoiceFilteredPropertyColumn as the fourth parameter? 
(IModel<List<? extends Y>> filterChoices)

Regards,
Linda

Linda van der Pal wrote:
> 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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ChoiceFilteredPropertyColumn and FilterToolbar examples

Posted by Linda van der Pal <lv...@heritageagenturen.nl>.
I found what I did wrong. I tried to let the filter-state be a Publisher 
as well. That should have been a BookListData object. The filterstate 
object should be the same type of object as the table contains, so you 
can filter on all variables. I hadn't understood that yet.

Thanks for the help anyway!

Regards,
Linda

Jeremy Thomerson wrote:
> Shouldn't the line below have "name" rather than "publisher"?  I
> haven't used this filtered thing in a while, but from your error,
> that's what it sounds like the problem is.  You're passing it a
> Publisher, and it's saying that it doesn't have a "publisher" field on
> it - because you told it to use the "publisher" field.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
>
> On Fri, May 1, 2009 at 2:31 AM, Linda van der Pal
> <lv...@heritageagenturen.nl> wrote:
>   
>>   columns[3] = new ChoiceFilteredPropertyColumn(new
>> Model<String>("Publisher"), "name", "publisher", createPublisherModel());
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>   
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.325 / Virus Database: 270.12.16/2094 - Release Date: 05/03/09 16:51:00
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ChoiceFilteredPropertyColumn and FilterToolbar examples

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Shouldn't the line below have "name" rather than "publisher"?  I
haven't used this filtered thing in a while, but from your error,
that's what it sounds like the problem is.  You're passing it a
Publisher, and it's saying that it doesn't have a "publisher" field on
it - because you told it to use the "publisher" field.

--
Jeremy Thomerson
http://www.wickettraining.com




On Fri, May 1, 2009 at 2:31 AM, Linda van der Pal
<lv...@heritageagenturen.nl> wrote:
>   columns[3] = new ChoiceFilteredPropertyColumn(new
> Model<String>("Publisher"), "name", "publisher", createPublisherModel());

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ChoiceFilteredPropertyColumn and FilterToolbar examples

Posted by Linda van der Pal <lv...@heritageagenturen.nl>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org