wicket.extensions.util.resource
Class TextTemplateSharedResourceFactory

java.lang.Object
  extended bywicket.extensions.util.resource.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) 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.

Author:
Jonathan Locke

Constructor Summary
TextTemplateSharedResourceFactory(TextTemplate template)
          Creates shared text template resources.
TextTemplateSharedResourceFactory(TextTemplate template, java.lang.Class scope)
          Creates shared text template resources with the given scope.
 
Method Summary
 wicket.ResourceReference resourceReference(java.util.Map variables)
           
protected  java.lang.String sharedResourceName(java.util.Map variables)
           
 
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 text template resources.

Parameters:
template - The template to interpolate into

TextTemplateSharedResourceFactory

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

Parameters:
template - The template to interpolate into
scope - The scope in shared resources to add resources at
Method Detail

resourceReference

public wicket.ResourceReference resourceReference(java.util.Map variables)
Parameters:
variables - The variables to interpolate into the template
Returns:
A resource reference to the template encoded as a resource with the given variables interpolated.

sharedResourceName

protected java.lang.String sharedResourceName(java.util.Map variables)
Parameters:
variables - Variables that parameterize the linked-to resource
Returns:
A unique name for the variables to use as a resource key


Copyright © 2004-2008 Wicket developers. All Rights Reserved.