001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.markup.html;
018
019import org.apache.wicket.Component;
020import org.apache.wicket.MarkupContainer;
021import org.apache.wicket.model.IModel;
022import org.apache.wicket.protocol.http.WebApplication;
023import org.apache.wicket.protocol.http.WebSession;
024import org.apache.wicket.request.http.WebRequest;
025import org.apache.wicket.request.http.WebResponse;
026
027/**
028 * A container of HTML markup and components. It is very similar to the base class MarkupContainer,
029 * except that it assumes that it is used in a web environment. Provides a convenience methods to get
030 * the current web objects (page, response, request, session).
031 * 
032 * @author Jonathan Locke
033 * @author Juergen Donnerstag
034 * 
035 */
036public class WebMarkupContainer extends MarkupContainer
037{
038        private static final long serialVersionUID = 1L;
039
040        /**
041         * @see Component#Component(String)
042         */
043        public WebMarkupContainer(final String id)
044        {
045                this(id, null);
046        }
047
048        /**
049         * @see Component#Component(String, IModel)
050         */
051        public WebMarkupContainer(final String id, IModel<?> model)
052        {
053                super(id, model);
054        }
055
056        /**
057         * A convenience method to return the WebPage. Same as getPage().
058         * 
059         * @return WebPage
060         */
061        public final WebPage getWebPage()
062        {
063                return (WebPage)getPage();
064        }
065
066        /**
067         * A convenience method to return the current WebRequest. Same as {@link org.apache.wicket.Component#getRequest()}.
068         *
069         * @return the current WebRequest
070         */
071        public final WebRequest getWebRequest()
072        {
073                return (WebRequest)getRequest();
074        }
075
076        /**
077         * A convenience method to return the current WebResponse. Same as {@link org.apache.wicket.Component#getResponse()}.
078         *
079         * @return the current WebResponse
080         */
081        public final WebResponse getWebResponse()
082        {
083                return (WebResponse)getResponse();
084        }
085
086        /**
087         * A convenience method to return the WebSession. Same as {@link org.apache.wicket.Component#getSession()} .
088         *
089         * @return the current WebSession
090         */
091        public final WebSession getWebSession()
092        {
093                return WebSession.get();
094        }
095
096        /**
097         * A convenience method to return the WebApplication. Same as {@link WebApplication#get()}.
098         *
099         * @return the current WebApplication
100         */
101        public final WebApplication getWebApplication()
102        {
103                return WebApplication.get();
104        }
105}