org.apache.wicket.markup.html.include
Class Include

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.markup.html.WebComponent
          extended by org.apache.wicket.markup.html.include.Include
All Implemented Interfaces:
Serializable, IClusterable, IConverterLocator

public class Include
extends WebComponent

Component that includes/ renders the import result of an URL, much like JSP include.

Use this to integrate non-Wicket locations in your page. This component is NOT meant for integrating more Wicket sources as a means of quick and dirty page composition. Use Panels, Borders and (Markup)inheritance for page composition instead.

You can feed this component the URL directly, or use a model that should deliver a valid URL. You can both use absolute (e.g. http://www.theserverside.com/) and relative (e.g. mydir/mypage.html) urls. This component will try to resolve relative urls to resources in the same webapplication.

The following example shows how to integrate a header and footer, coming from a plain HTML source on the same server is integrated using this component. The files footer.html and header.html would be located in the web application root directory

Java:

   ...
        add(new Include("header", "header.html"));
        add(new Include("footer", "footer.html"));
   ...
 
Html:
   ...
        <div>
         <div wicket:id="header">header comes here</div>
         <div>I am the body!</div>
         <div wicket:id="footer">footer comes here</div>
        </div>
   ...
 

Author:
Eelco Hillenius
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.Component
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor<T extends Component>, Component.VisibilityChange
 
Field Summary
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Constructor Summary
Include(String id)
          Construct.
Include(String id, IModel<String> model)
          Construct.
Include(String id, String modelObject)
          Construct.
 
Method Summary
protected  String importAsString()
          Imports the contents of the url of the model object.
protected  boolean isAbsolute(String url)
          Gets whether the given url is absolute (true) or relative (false).
protected  void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
          Processes the body.
 
Methods inherited from class org.apache.wicket.markup.html.WebComponent
onRender
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, configure, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviors, getBehaviors, getBehaviorsRawList, getClassRelativePath, getComponentBorder, getConverter, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdImpl, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, onAfterRender, onAttach, onBeforeRender, onBeginRequest, onComponentTag, onConfigure, onDetach, onEndRequest, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setDefaultModel, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupIdImpl, setMarkupStream, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, toString, toString, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Include

public Include(String id)
Construct.

Parameters:
id - component id

Include

public Include(String id,
               IModel<String> model)
Construct.

Parameters:
id - component id
model - the model

Include

public Include(String id,
               String modelObject)
Construct.

Parameters:
id - component id
modelObject - the model object (will be wrapped in a model)
Method Detail

importAsString

protected String importAsString()
Imports the contents of the url of the model object.

Returns:
the imported contents

onComponentTagBody

protected void onComponentTagBody(MarkupStream markupStream,
                                  ComponentTag openTag)
Description copied from class: Component
Processes the body.

Overrides:
onComponentTagBody in class Component
Parameters:
markupStream - The markup stream
openTag - The open tag for the body
See Also:
Component.onComponentTagBody(org.apache.wicket.markup.MarkupStream, org.apache.wicket.markup.ComponentTag)

isAbsolute

protected final boolean isAbsolute(String url)
Gets whether the given url is absolute (true) or relative (false).

Parameters:
url - the url
Returns:
whether the given url is absolute (true) or relative (false)


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.