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.velocity;
18:
19: import java.util.ArrayList;
20: import java.util.Iterator;
21: import java.util.List;
22:
23: import org.apache.wicket.Component;
24: import org.apache.wicket.behavior.AbstractHeaderContributor;
25: import org.apache.wicket.markup.html.IHeaderContributor;
26:
27: /**
28: * a simple header contributor that delegates to a List of
29: * {@link VelocityContributor}
30: *
31: */
32: public class VelocityHeaderContributor extends
33: AbstractHeaderContributor {
34:
35: private final List contributors = new ArrayList(1);
36:
37: /**
38: * Adds a contributor.
39: *
40: * @param velocityContributor
41: * @return This for chaining
42: */
43: public VelocityHeaderContributor add(
44: VelocityContributor velocityContributor) {
45: contributors.add(velocityContributor);
46: return this ;
47: }
48:
49: /**
50: * @see org.apache.wicket.behavior.AbstractBehavior#detach(org.apache.wicket.Component)
51: */
52: public void detach(Component component) {
53: for (Iterator i = contributors.iterator(); i.hasNext();) {
54: VelocityContributor vc = (VelocityContributor) i.next();
55: vc.detach(component);
56: }
57: }
58:
59: /**
60: * @see org.apache.wicket.behavior.AbstractHeaderContributor#getHeaderContributors()
61: */
62: public IHeaderContributor[] getHeaderContributors() {
63: return (IHeaderContributor[]) contributors
64: .toArray(new IHeaderContributor[contributors.size()]);
65: }
66: }
|