2 * Copyright 2005-2010 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.wicket.behavior;
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.List;
22 import org.apache.wicket.markup.html.WebPage;
23 import org.apache.wicket.protocol.http.WebResponse;
26 * Implements a composite page behavior which invokes all behaviors in the order they were
29 * To use this in an arbitrary page, override <code>onBeforeRender()</code>,
30 * <code>setHeaders()</code> and <code>onAfterRender</code> in the page and delegate to the
31 * corresponding methods in this class.
33 * @author Erik Brakkee
35 public class CompositePageBehavior implements PageBehavior {
37 private List<PageBehavior> behaviors;
40 * Constructs the compositie.
42 public CompositePageBehavior() {
43 behaviors = new ArrayList<PageBehavior>();
48 * @param aBehavior Behavior
50 public void add(PageBehavior aBehavior) {
51 behaviors.add(aBehavior);
55 public void onAfterRender(WebPage aPage) {
56 for (PageBehavior behavior: behaviors) {
57 behavior.onAfterRender(aPage);
62 public void onBeforeRender(WebPage aPage) {
63 for (PageBehavior behavior: behaviors) {
64 behavior.onBeforeRender(aPage);
69 public void setHeaders(WebPage aPage, WebResponse aResponse) {
70 for (PageBehavior behavior: behaviors) {
71 behavior.setHeaders(aPage, aResponse);