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

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

added field table for record by means of a data provider (of the new DocumentField? pojo interface, plus hybrid model/implementation) with filtering capabilities and a dataview that produces a table

File size: 2.0 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.DocumentField;
20import org.apache.wicket.markup.html.basic.Label;
21import org.apache.wicket.markup.html.list.ListItem;
22import org.apache.wicket.markup.html.list.ListView;
23import org.apache.wicket.markup.html.panel.Panel;
24import org.apache.wicket.markup.repeater.Item;
25import org.apache.wicket.markup.repeater.data.DataView;
26import org.apache.wicket.markup.repeater.data.IDataProvider;
27import org.apache.wicket.model.IModel;
28import org.apache.wicket.model.PropertyModel;
29
30/**
31 *
32 * @author twagoo
33 */
34public class FieldsTablePanel extends Panel {
35
36    public FieldsTablePanel(String id, IDataProvider<DocumentField> fieldProvider) {
37        super(id);
38        add(new DataView<DocumentField>("documentField", fieldProvider) {
39
40            @Override
41            protected void populateItem(Item<DocumentField> item) {
42                final IModel<DocumentField> fieldModel = item.getModel();
43                item.add(new Label("fieldName", new PropertyModel(fieldModel, "fieldName")));
44                item.add(new ListView("values", new PropertyModel(fieldModel, "values")) {
45
46                    @Override
47                    protected void populateItem(ListItem item) {
48                        item.add(new Label("value", item.getModel()));
49                    }
50                });
51            }
52        });
53    }
54
55}
Note: See TracBrowser for help on using the repository browser.