01: /*
02: * $Id: OddEvenItem.java 462103 2006-09-05 22:32:17Z ehillenius $ $Revision: 462103 $ $Date: 2006-09-06 00:32:17 +0200 (Wed, 06 Sep 2006) $
03: *
04: * ==============================================================================
05: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
06: * use this file except in compliance with the License. You may obtain a copy of
07: * 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, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package wicket.extensions.markup.html.repeater.refreshing;
18:
19: import wicket.markup.ComponentTag;
20: import wicket.model.IModel;
21:
22: /**
23: * Item that sets class="even" or class="odd" attributes based on its index
24: *
25: * @author Igor Vaynberg (ivaynberg)
26: *
27: */
28: public class OddEvenItem extends Item {
29: private static final long serialVersionUID = 1L;
30:
31: private String CLASS_EVEN = "even";
32: private String CLASS_ODD = "odd";
33:
34: /**
35: * Constructor
36: *
37: * @param id
38: * component id
39: * @param index
40: * item index
41: * @param model
42: * item model
43: */
44: public OddEvenItem(String id, int index, IModel model) {
45: super (id, index, model);
46: }
47:
48: protected void onComponentTag(ComponentTag tag) {
49: super .onComponentTag(tag);
50: tag
51: .put("class", (getIndex() % 2 == 0) ? CLASS_EVEN
52: : CLASS_ODD);
53: }
54:
55: }
|