org.apache.wicket.markup
Class MarkupFactory

java.lang.Object
  extended by org.apache.wicket.markup.MarkupFactory

public class MarkupFactory
extends java.lang.Object

Markup loading essentially is an autark modul of Wicket. MarkupFactory provides all the means to change defaults.

Author:
Juergen Donnerstag

Constructor Summary
MarkupFactory()
          Construct.
 
Method Summary
static MarkupFactory get()
           
 IMarkupFragment getMarkup(MarkupContainer container, boolean enforceReload)
          Gets a fresh markup stream that contains the (immutable) markup resource for this class.
 Markup getMarkup(MarkupContainer container, java.lang.Class<?> clazz, boolean enforceReload)
          Gets a fresh markup stream that contains the (immutable) markup resource for this class.
 IMarkupCache getMarkupCache()
          The markup cache also loads the markup if not yet available in the cache.
 IMarkupLoader getMarkupLoader()
          In case there is a need to extend the default chain of MarkupLoaders
 MarkupResourceStream getMarkupResourceStream(MarkupContainer container, java.lang.Class<?> clazz)
          Create a new markup resource stream for the container.
protected  IMarkupResourceStreamProvider getMarkupResourceStreamProvider(MarkupContainer container)
          Get the markup resource stream provider to be used
 boolean hasAssociatedMarkup(MarkupContainer container)
          Check if container has associated markup
 boolean hasMarkupCache()
          return if markup cache has been initialized yet
 Markup loadMarkup(MarkupContainer container, MarkupResourceStream markupResourceStream, boolean enforceReload)
          Loads markup from a resource stream.
 MarkupParser newMarkupParser(MarkupResourceStream resource)
          Create a new markup parser.
protected  IMarkupFilter onAppendMarkupFilter(IMarkupFilter filter)
          a) Allow subclasses to configure individual Wicket filters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkupFactory

public MarkupFactory()
Construct.

Method Detail

get

public static final MarkupFactory get()
Returns:
The markup factory associated with the application

getMarkupLoader

public IMarkupLoader getMarkupLoader()
In case there is a need to extend the default chain of MarkupLoaders

Returns:
MarkupLoader

newMarkupParser

public MarkupParser newMarkupParser(MarkupResourceStream resource)
Create a new markup parser.

In case you want to add you own markup filters, than subclass the method and call WicketMarkupParser#add(IMarkupFilter) for your own filter on the markup parser returned.

Parameters:
resource -
Returns:
A new markup parser

onAppendMarkupFilter

protected IMarkupFilter onAppendMarkupFilter(IMarkupFilter filter)
a) Allow subclasses to configure individual Wicket filters

b) Allow to replace default filter with extended one

c) Allows to disable Wicket filters via returning false

Parameters:
filter -
Returns:
The filter to be added. Null to ignore.

getMarkupCache

public IMarkupCache getMarkupCache()
The markup cache also loads the markup if not yet available in the cache.

Returns:
Null, to disable caching.

hasMarkupCache

public boolean hasMarkupCache()
return if markup cache has been initialized yet

Returns:
true if markup cache was already initialized, false otherwise

getMarkup

public final IMarkupFragment getMarkup(MarkupContainer container,
                                       boolean enforceReload)
Gets a fresh markup stream that contains the (immutable) markup resource for this class.

Parameters:
container - The container the markup should be associated with
enforceReload - The cache will be ignored and all, including inherited markup files, will be reloaded. Whatever is in the cache, it will be ignored
Returns:
A stream of MarkupElement elements

getMarkup

public final Markup getMarkup(MarkupContainer container,
                              java.lang.Class<?> clazz,
                              boolean enforceReload)
Gets a fresh markup stream that contains the (immutable) markup resource for this class.

Parameters:
container - The container the markup should be associated with
clazz - Must be the container class or any of its super classes.
enforceReload - The cache will be ignored and all, including inherited markup files, will be reloaded. Whatever is in the cache, it will be ignored
Returns:
A stream of MarkupElement elements

hasAssociatedMarkup

public final boolean hasAssociatedMarkup(MarkupContainer container)
Check if container has associated markup

Parameters:
container - The container the markup should be associated with
Returns:
True if this markup container has associated markup

getMarkupResourceStreamProvider

protected final IMarkupResourceStreamProvider getMarkupResourceStreamProvider(MarkupContainer container)
Get the markup resource stream provider to be used

Parameters:
container - The MarkupContainer requesting the markup resource stream
Returns:
IMarkupResourceStreamProvider

getMarkupResourceStream

public final MarkupResourceStream getMarkupResourceStream(MarkupContainer container,
                                                          java.lang.Class<?> clazz)
Create a new markup resource stream for the container.

Note: usually it will only called once, as the IResourceStream will be cached by MarkupCache.

Parameters:
container - The MarkupContainer which requests to load the Markup resource stream
clazz - Either the container class or any super class
Returns:
A IResourceStream if the resource was found

loadMarkup

public final Markup loadMarkup(MarkupContainer container,
                               MarkupResourceStream markupResourceStream,
                               boolean enforceReload)
Loads markup from a resource stream.

Parameters:
container - The original requesting markup container
markupResourceStream - The markup resource stream to load. May be null.
enforceReload - The cache will be ignored and all, including inherited markup files, will be reloaded. Whatever is in the cache, it will be ignored
Returns:
The markup


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