org.apache.tiles.freemarker.template.PutAttributeFMModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tiles-freemarker Show documentation
Show all versions of tiles-freemarker Show documentation
Support for FreeMarker in Apache Tiles. For more read http://tiles.apache.org/framework/tutorial/integration/freemarker.html. Upgraded to the Jakarta EE platform.
The newest version!
/*
* This file was automatically generated by Apache Tiles Autotag.
*/
package org.apache.tiles.freemarker.template;
import java.io.IOException;
import java.util.Map;
import org.apache.tiles.autotag.core.runtime.ModelBody;
import org.apache.tiles.autotag.core.runtime.AutotagRuntime;
import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
/**
*
* Put an attribute in enclosing attribute container tag.
*
*
* Enclosing attribute container tag can be :
*
* - <initContainer>
* - <definition>
* - <insertAttribute>
* - <insertDefinition>
* - <putListAttribute>
*
* (or any other tag which implements the PutAttributeTagParent
* interface. Exception is thrown if no appropriate tag can be found.
*
*
* Put tag can have following atributes :
*
* - name : Name of the attribute
* - value : value to put as attribute
* - type : value type. Possible type are : string (value is used as direct
* string), template (value is used as a page url to insert), definition (value
* is used as a definition name to insert), object (value is used as it is)
* - role : Role to check when 'insertAttribute' will be called.
*
*
*
* Value can also come from tag body. Tag body is taken into account only if
* value is not set by one of the tag attributes. In this case Attribute type is
* "string", unless tag body define another type.
*
*/
public class PutAttributeFMModel implements TemplateDirectiveModel {
/**
* The template model.
*/
private org.apache.tiles.template.PutAttributeModel model;
/**
* Constructor.
*
* @param model
* The template model.
*/
public PutAttributeFMModel(org.apache.tiles.template.PutAttributeModel model) {
this.model = model;
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body) throws TemplateException, IOException {
AutotagRuntime runtime = new org.apache.tiles.request.freemarker.autotag.FreemarkerAutotagRuntime();
if (runtime instanceof TemplateDirectiveModel) {
((TemplateDirectiveModel) runtime).execute(env, params, loopVars, body);
}
org.apache.tiles.request.Request request = runtime.createRequest();
ModelBody modelBody = runtime.createModelBody();
model.execute(
runtime.getParameter("name", java.lang.String.class, null),
runtime.getParameter("value", java.lang.Object.class, null),
runtime.getParameter("expression", java.lang.String.class, null),
runtime.getParameter("role", java.lang.String.class, null),
runtime.getParameter("type", java.lang.String.class, null),
runtime.getParameter("cascade", java.lang.Boolean.class, false),
request, modelBody
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy