org.apache.wicket.markup.parser.filter
Class WicketLinkTagHandler

java.lang.Object
  extended by org.apache.wicket.markup.parser.AbstractMarkupFilter
      extended by org.apache.wicket.markup.parser.filter.BaseMarkupFilter
          extended by org.apache.wicket.markup.parser.filter.WicketLinkTagHandler
All Implemented Interfaces:
Serializable, IClusterable, IMarkupFilter, IComponentResolver

public class WicketLinkTagHandler
extends BaseMarkupFilter
implements IComponentResolver

This is a markup inline filter. It identifies xml tags which include a href attribute and which are not Wicket specific components and flags these tags (ComponentTag) as autolink enabled. A component resolver will later resolve the href and assign a BookmarkablePageLink to it (automatically).

An application setting is used as default value, which might be modified for specific regions. These regions are identified by <wicket:link> tags with an optional 'autolink' attribute. The default value for the attribute is true, thus enabling autolinking. An open-close <wicket:link/> tag will change the autolink status until the end of the markup document or the next <wicket:link> tag respectively. <wicket:link> regions may be nested.

Author:
Juergen Donnerstag
See Also:
Serialized Form

Field Summary
static String AUTOLINK_ID
          The id of autolink components
static String LINK
           
 
Constructor Summary
WicketLinkTagHandler()
          Construct.
 
Method Summary
protected  boolean analyzeAutolinkCondition(ComponentTag tag)
          Analyze the tag.
protected  MarkupElement nextTag(ComponentTag tag)
          Invoked with the next ComponentTag
 Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)
          Try to resolve the tag, then create a component, add it to the container and render it.
 void setAutomaticLinking(boolean enable)
          Set the default value for autolinking
 
Methods inherited from class org.apache.wicket.markup.parser.filter.BaseMarkupFilter
nextTag
 
Methods inherited from class org.apache.wicket.markup.parser.AbstractMarkupFilter
getCount, getNextFilter, nextComponentTag, setNextFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINK

public static final String LINK
See Also:
Constant Field Values

AUTOLINK_ID

public static final String AUTOLINK_ID
The id of autolink components

See Also:
Constant Field Values
Constructor Detail

WicketLinkTagHandler

public WicketLinkTagHandler()
Construct.

Method Detail

setAutomaticLinking

public void setAutomaticLinking(boolean enable)
Set the default value for autolinking

Parameters:
enable - if true, autolinks are enabled

nextTag

protected final MarkupElement nextTag(ComponentTag tag)
                               throws ParseException
Description copied from class: BaseMarkupFilter
Invoked with the next ComponentTag

Specified by:
nextTag in class BaseMarkupFilter
Returns:
the next tag
Throws:
ParseException

analyzeAutolinkCondition

protected boolean analyzeAutolinkCondition(ComponentTag tag)
Analyze the tag. If return value == true, a autolink component will be created.

Subclass analyzeAutolinkCondition() to implement you own implementation and register the new tag handler with the markup parser through Application.newMarkupParser().

Parameters:
tag - The current tag being parsed
Returns:
If true, tag will become auto-component

resolve

public Component resolve(MarkupContainer container,
                         MarkupStream markupStream,
                         ComponentTag tag)
Description copied from interface: IComponentResolver
Try to resolve the tag, then create a component, add it to the container and render it.

Specified by:
resolve in interface IComponentResolver
Parameters:
container - The container parsing its markup
markupStream - The current markupStream
tag - The current component tag while parsing the markup
Returns:
null, if not found


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