org.apache.wicket.util.template
Class TextTemplateSharedResourceFactory

java.lang.Object
  extended by org.apache.wicket.util.template.TextTemplateSharedResourceFactory

public class TextTemplateSharedResourceFactory
extends java.lang.Object

A resource (reference) factory that takes a TextTemplate and generates shared resources for various interpolations of that template.

A scope for adding shared resources allows you to limit the namespace impact of the shared resources created. If you omit the scope, the application-wide scope Application.class will be used by default.

You may use resources created by this factory directly by calling resourceReference(Map) to get a resource reference to the given shared resource interpolation represented by the variables in the Map. Or, for convenience, you can use TextTemplateLink to link to resources created by this factory.

In many cases, it will be useful to extend this class and override sharedResourceName(Map) in order to provide a unique name for resources created by the factory using map values. If you don't provide an override, every value in the map will be used to produce the unique name, which may create either longer names or more unique shared resources than you really wanted.

Since:
1.2.6
Author:
Jonathan Locke

Constructor Summary
TextTemplateSharedResourceFactory(TextTemplate template)
          Creates shared TextTemplate resources.
TextTemplateSharedResourceFactory(TextTemplate template, java.lang.Class scope)
          Creates shared TextTemplate resources with the given scope.
 
Method Summary
 ResourceReference resourceReference(java.util.Map variables)
          Interpolates the given variables Map and returns a ResourceReference.
protected  java.lang.String sharedResourceName(java.util.Map variables)
          Returns a unique name for the variables to use as a resource key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTemplateSharedResourceFactory

public TextTemplateSharedResourceFactory(TextTemplate template)
Creates shared TextTemplate resources.

Parameters:
template - the TextTemplate to interpolate into

TextTemplateSharedResourceFactory

public TextTemplateSharedResourceFactory(TextTemplate template,
                                         java.lang.Class scope)
Creates shared TextTemplate resources with the given scope.

Parameters:
template - the TextTemplate to interpolate into
scope - the scope in shared resources at which to add resources
Method Detail

resourceReference

public ResourceReference resourceReference(java.util.Map variables)
Interpolates the given variables Map and returns a ResourceReference.

Parameters:
variables - the variables to interpolate into the template
Returns:
a ResourceReference to the template encoded as a resource with the given variables interpolated

sharedResourceName

protected java.lang.String sharedResourceName(java.util.Map variables)
Returns a unique name for the variables to use as a resource key.

Parameters:
variables - variables that parameterize the linked-to resource
Returns:
a unique name for the variables to use as a resource key


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