Class AbstractExtensibilityDirective
- All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel,freemarker.template.TemplateModel,ExtensibilityDirective
- Direct Known Subclasses:
MarkupDirective
Defines the abstract behaviour of an extensibility directive by implementing the common structure. An extensibility directive has the following attributes:
- id: The identifier of the directive to declare or modify
- action: The action to before (merge is the implicit default action)
- target: The identifier of the directive that some actions use as a relative target (i.e. when adding new content)
- merge: Merges content into the model
- remove: Removes content from the model
- replace: Replaces content in the model
- modify: Modifies existing content in the model
- before: Places new content before existing content in the model
- after: Places new content after existing content in the model
- Author:
- David Draper
-
Field Summary
Fields inherited from interface org.springframework.extensions.surf.extensibility.ExtensibilityDirective
ACTION, ACTION_AFTER, ACTION_BEFORE, ACTION_MERGE, ACTION_MODIFY, ACTION_REMOVE, ACTION_REPLACE, DIRECTIVE_ID, TARGETFields inherited from interface freemarker.template.TemplateModel
NOTHING -
Constructor Summary
ConstructorsConstructorDescriptionAbstractExtensibilityDirective(String directiveName, ExtensibilityModel model) Requires a DirectiveModel to contribute to. -
Method Summary
Modifier and TypeMethodDescriptionvoidafter(ExtensibilityDirectiveData directiveData) The default implementation of this action is simply to delegate the request to theExtensibilityModel.after()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.voidbefore(ExtensibilityDirectiveData directiveData) The default implementation of this action is simply to delegate the request to theExtensibilityModel.before()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.createExtensibilityDirectiveData(String id, String action, String target, Map params, freemarker.template.TemplateDirectiveBody body, freemarker.core.Environment env) Creates and returns aDefaultExtensibilityDirectiveDataobject containing the primary data needed for processing the current directive invocation.voidexecute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) getId()getModel()voidmerge(ExtensibilityDirectiveData directiveData, Map<String, Object> params) Merges the output of directive data into the content model.voidremove(ExtensibilityDirectiveData directiveData) The default implementation of this action is simply to delegate the request to theExtensibilityModel.remove()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.voidreplace(ExtensibilityDirectiveData directiveData) The default implementation of this action is simply to delegate the request to theExtensibilityModel.replace()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.Methods inherited from class org.springframework.extensions.surf.extensibility.impl.AbstractFreeMarkerDirective
getBooleanProperty, getDirectiveName, getStringProperty
-
Constructor Details
-
AbstractExtensibilityDirective
Requires a DirectiveModel to contribute to.- Parameters:
directiveName- Stringmodel- ExtensibilityModel
-
-
Method Details
-
getId
-
getModel
-
createExtensibilityDirectiveData
public ExtensibilityDirectiveData createExtensibilityDirectiveData(String id, String action, String target, Map params, freemarker.template.TemplateDirectiveBody body, freemarker.core.Environment env) throws freemarker.template.TemplateException Creates and returns a
DefaultExtensibilityDirectiveDataobject containing the primary data needed for processing the current directive invocation. This object is required when building the model becauseTemplateDirectiveModelinstances are re-used so the data assigned to them is volatile.Extending classes implementing concrete directives should choose to override this method if the directive being defined requires additional data or needs to instantiate different
ContentModelElementinstances in order to provide more advance content processing.- Parameters:
id- The id of the current directive invocationaction- The action of the current directive invocationtarget- The target of the current directive invocation (this could be null)params- The parameters used by the directive invocation.body- TheTemplateDirectiveBodyof the current directive invocation.env- The current FreeMarker templateEnvironment- Returns:
- A new
DefaultExtensibilityDirectiveDataobject containing the data supplied as parameters to the method call. - Throws:
freemarker.template.TemplateException
-
execute
public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException - Specified by:
executein interfacefreemarker.template.TemplateDirectiveModel- Throws:
freemarker.template.TemplateExceptionIOException
-
merge
public void merge(ExtensibilityDirectiveData directiveData, Map<String, Object> params) throws freemarker.template.TemplateException, IOExceptionMerges the output of directive data into the content model.
The default implementation of this action is simply to delegate the request to the
ExtensibilityModel.merge()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.- Parameters:
directiveData- ExtensibilityDirectiveDataparams- Map<String, Object>- Throws:
freemarker.template.TemplateExceptionIOException
-
before
public void before(ExtensibilityDirectiveData directiveData) throws freemarker.template.TemplateException, IOException The default implementation of this action is simply to delegate the request to the
ExtensibilityModel.before()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.- Parameters:
directiveData- ExtensibilityDirectiveData- Throws:
freemarker.template.TemplateExceptionIOException
-
after
public void after(ExtensibilityDirectiveData directiveData) throws freemarker.template.TemplateException, IOException The default implementation of this action is simply to delegate the request to the
ExtensibilityModel.after()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.- Parameters:
directiveData- ExtensibilityDirectiveData- Throws:
freemarker.template.TemplateExceptionIOException
-
remove
public void remove(ExtensibilityDirectiveData directiveData) throws freemarker.template.TemplateException, IOException The default implementation of this action is simply to delegate the request to the
ExtensibilityModel.remove()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.- Parameters:
directiveData- ExtensibilityDirectiveData- Throws:
freemarker.template.TemplateExceptionIOException
-
replace
public void replace(ExtensibilityDirectiveData directiveData) throws freemarker.template.TemplateException, IOException The default implementation of this action is simply to delegate the request to the
ExtensibilityModel.replace()method but this has been abstracted into its own method so that extending directives can easily modify the default behaviour of this action.- Parameters:
directiveData- ExtensibilityDirectiveData- Throws:
freemarker.template.TemplateExceptionIOException
-