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.sort;
18:
19: import org.apache.wicket.markup.html.border.Border;
20:
21: /**
22: * A component that wraps markup with an OrderByLink. This has the advantage of
23: * being able to add the attribute modifier to the wrapping element as opposed
24: * to the link, so that it can be attached to <th> or any other element.
25: *
26: * For example:
27: *
28: * <th wicket:id="order-by-border">Heading</th>
29: *
30: *
31: * @author Igor Vaynberg ( ivaynberg )
32: *
33: */
34: public class OrderByBorder extends Border {
35: private static final long serialVersionUID = 1L;
36:
37: /**
38: * @param id
39: * see
40: * {@link OrderByLink#OrderByLink(String, String, ISortStateLocator, OrderByLink.ICssProvider) }
41: * @param property
42: * see
43: * {@link OrderByLink#OrderByLink(String, String, ISortStateLocator, OrderByLink.ICssProvider) }
44: * @param stateLocator
45: * see
46: * {@link OrderByLink#OrderByLink(String, String, ISortStateLocator, OrderByLink.ICssProvider) }
47: * @param cssProvider
48: * see
49: * {@link OrderByLink#OrderByLink(String, String, ISortStateLocator, OrderByLink.ICssProvider) }
50: */
51: public OrderByBorder(String id, String property,
52: ISortStateLocator stateLocator,
53: OrderByLink.ICssProvider cssProvider) {
54: super (id);
55: OrderByLink link = new OrderByLink("orderByLink", property,
56: stateLocator, OrderByLink.VoidCssProvider.getInstance()) {
57:
58: private static final long serialVersionUID = 1L;
59:
60: protected void onSortChanged() {
61: OrderByBorder.this .onSortChanged();
62: }
63: };
64: add(link);
65: add(new OrderByLink.CssModifier(link, cssProvider));
66: link.add(getBodyContainer());
67: }
68:
69: /**
70: * This method is a hook for subclasses to perform an action after sort has
71: * changed
72: */
73: protected void onSortChanged() {
74: // noop
75: }
76:
77: /**
78: * @param id
79: * see
80: * {@link OrderByLink#OrderByLink(String, String, ISortStateLocator)}
81: * @param property
82: * see
83: * {@link OrderByLink#OrderByLink(String, String, ISortStateLocator)}
84: * @param stateLocator
85: * see
86: * {@link OrderByLink#OrderByLink(String, String, ISortStateLocator)}
87: */
88: public OrderByBorder(String id, String property,
89: ISortStateLocator stateLocator) {
90: this(id, property, stateLocator, OrderByLink.DefaultCssProvider
91: .getInstance());
92: }
93:
94: }
|