01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.extensions.markup.html.repeater.data.grid;
18:
19: import org.apache.wicket.IClusterable;
20: import org.apache.wicket.markup.repeater.Item;
21: import org.apache.wicket.model.IDetachable;
22: import org.apache.wicket.model.IModel;
23:
24: /**
25: * Represents an object that is capable of populating an {@link Item} container
26: * representing a cell in a {@link DataGridView} with components.
27: * <p>
28: * Example
29: * <p>
30: *
31: * <pre>
32: * class NamePopulator implements ICellPopulator
33: * {
34: * void populateItem(final Item cellItem, final String componentId, final IModel rowModel) {
35: * User user=(User)rowModel.getObject(cellItem);
36: * String name=user.getFirstName()+" "+user.getLastName();
37: * cellItem.add(new Label(componentId, name);
38: * }}
39: * </pre>
40: *
41: * In this example the IDataProvider assigned to the DataGridView retrieves User
42: * objects from the database. The cell populator adds a label to the cell that
43: * will display the full name of the user.
44: *
45: * @see DataGridView
46: * @see Item
47: *
48: * @author Igor Vaynberg (ivaynberg)
49: *
50: */
51: public interface ICellPopulator extends IClusterable, IDetachable {
52: /**
53: * Method used to populate a cell in the {@link DataGridView}
54: *
55: * <b>Implementation MUST add a component to the cellItem using the
56: * component id provided by componentId argument, otherwise a
57: * WicketRuntimeException will be thrown</b>
58: *
59: * @param cellItem
60: * the item representing the current table cell being rendered
61: * @param componentId
62: * the id of the component used to render the cell (only one
63: * component should be added to the cell)
64: * @param rowModel
65: * the model of the row item being rendered. this model usually
66: * contains the model provided by the data provider.
67: *
68: * @see Item
69: */
70: void populateItem(final Item cellItem, final String componentId,
71: final IModel rowModel);
72: }
|