source: vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/FacetsPanel.java @ 4599

Last change on this file since 4599 was 4599, checked in by Twan Goosen, 10 years ago

Ajax updating on facet value selection

File size: 2.4 KB
Line 
1/*
2 * Copyright (C) 2014 CLARIN
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17package eu.clarin.cmdi.vlo.wicket.components;
18
19import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
20import eu.clarin.cmdi.vlo.wicket.model.FacetSelectionModel;
21import java.util.List;
22import org.apache.solr.client.solrj.response.FacetField;
23import org.apache.wicket.ajax.AjaxRequestTarget;
24import org.apache.wicket.markup.html.list.ListItem;
25import org.apache.wicket.markup.html.list.ListView;
26import org.apache.wicket.markup.html.panel.Panel;
27import org.apache.wicket.model.IModel;
28
29/**
30 * A panel representing a group of facets.
31 *
32 * For each facet present in the provided list model, a {@link FacetPanel} is
33 * added to the a list view.
34 *
35 * @author twagoo
36 */
37public abstract class FacetsPanel extends Panel {
38
39    /**
40     *
41     * @param id component id
42     * @param facetsModel model that provides the list of facets to show in this
43     * panel
44     * @param selectionModel model representing the current query/value
45     * selection state
46     */
47    public FacetsPanel(final String id, final IModel<List<FacetField>> facetsModel, final IModel<QueryFacetsSelection> selectionModel) {
48        super(id, selectionModel);
49
50        add(new ListView<FacetField>("facets", facetsModel) {
51
52            @Override
53            protected void populateItem(ListItem<FacetField> item) {
54                item.add(
55                        new FacetPanel("facet", new FacetSelectionModel(item.getModel(), selectionModel)) {
56
57                            @Override
58                            protected void selectionChanged(AjaxRequestTarget target) {
59                                FacetsPanel.this.selectionChanged(target);
60                            }
61                        }
62                );
63            }
64        });
65    }
66   
67    protected abstract void selectionChanged(AjaxRequestTarget target);
68}
Note: See TracBrowser for help on using the repository browser.