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.model.IModel; 021import org.apache.wicket.protocol.http.WebApplication; 022import org.apache.wicket.protocol.http.WebSession; 023import org.apache.wicket.request.http.WebRequest; 024import org.apache.wicket.request.http.WebResponse; 025 026/** 027 * Base class for simple HTML components which do not hold nested components. If you need to support 028 * nested components, see WebMarkupContainer or use Panel if the component will have its own 029 * associated markup. 030 * 031 * @see org.apache.wicket.markup.html.WebMarkupContainer 032 * 033 * @author Jonathan Locke 034 * @author Juergen Donnerstag 035 * @author Eelco Hillenius 036 */ 037public class WebComponent extends Component 038{ 039 private static final long serialVersionUID = 1L; 040 041 /** 042 * @see Component#Component(String) 043 */ 044 public WebComponent(final String id) 045 { 046 super(id); 047 } 048 049 /** 050 * @see Component#Component(String, IModel) 051 */ 052 public WebComponent(final String id, final IModel<?> model) 053 { 054 super(id, model); 055 } 056 057 @Override 058 protected void onRender() 059 { 060 internalRenderComponent(); 061 } 062 063 064 /** 065 * A convenience method to return the WebPage. Same as getPage(). 066 * 067 * @return WebPage 068 */ 069 public final WebPage getWebPage() 070 { 071 return (WebPage)getPage(); 072 } 073 074 /** 075 * A convenience method to return the current WebRequest. Same as {@link org.apache.wicket.Component#getRequest()}. 076 * 077 * @return the current WebRequest 078 */ 079 public final WebRequest getWebRequest() 080 { 081 return (WebRequest)getRequest(); 082 } 083 084 /** 085 * A convenience method to return the current WebResponse. Same as {@link org.apache.wicket.Component#getResponse()}. 086 * 087 * @return the current WebResponse 088 */ 089 public final WebResponse getWebResponse() 090 { 091 return (WebResponse)getResponse(); 092 } 093 094 /** 095 * A convenience method to return the WebSession. Same as {@link org.apache.wicket.Component#getSession()} . 096 * 097 * @return the current WebSession 098 */ 099 public final WebSession getWebSession() 100 { 101 return WebSession.get(); 102 } 103 104 /** 105 * A convenience method to return the WebApplication. Same as {@link WebApplication#get()}. 106 * 107 * @return the current WebApplication 108 */ 109 public final WebApplication getWebApplication() 110 { 111 return WebApplication.get(); 112 } 113}