本文整理汇总了Java中freemarker.template.TemplateModelException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java TemplateModelException.getMessage方法的具体用法?Java TemplateModelException.getMessage怎么用?Java TemplateModelException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freemarker.template.TemplateModelException
的用法示例。
在下文中一共展示了TemplateModelException.getMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: autoWrap
import freemarker.template.TemplateModelException; //导入方法依赖的package包/类
public static TemplateModel autoWrap(Object obj, Environment env) {
TemplateModel templateModelObj = null;
try {
templateModelObj = getDefaultOfbizWrapper().wrap(obj);
} catch (TemplateModelException e) {
throw new RuntimeException(e.getMessage());
}
return templateModelObj;
}
示例2: getInternalEngine
import freemarker.template.TemplateModelException; //导入方法依赖的package包/类
protected Configuration getInternalEngine() throws IOException, TemplateException{
try {
BeansWrapper beansWrapper = new BeansWrapper(Configuration.VERSION_2_3_23);
this.templateModel = beansWrapper.getStaticModels().get(String.class.getName());
} catch (TemplateModelException e) {
throw new IOException(e.getMessage(),e.getCause());
}
// 创建 Configuration 实例
Configuration config = new Configuration(Configuration.VERSION_2_3_23);
Properties props = ConfigUtils.filterWithPrefix("docx4j.freemarker.", "docx4j.freemarker.", Docx4jProperties.getProperties(), false);
// FreeMarker will only accept known keys in its setSettings and
// setAllSharedVariables methods.
if (!props.isEmpty()) {
config.setSettings(props);
}
if (this.freemarkerVariables != null && !this.freemarkerVariables.isEmpty()) {
config.setAllSharedVariables(new SimpleHash(this.freemarkerVariables, config.getObjectWrapper()));
}
if (this.defaultEncoding != null) {
config.setDefaultEncoding(this.defaultEncoding);
}
List<TemplateLoader> templateLoaders = new LinkedList<TemplateLoader>(this.templateLoaders);
// Register template loaders that are supposed to kick in early.
if (this.preTemplateLoaders != null) {
templateLoaders.addAll(this.preTemplateLoaders);
}
postProcessTemplateLoaders(templateLoaders);
// Register template loaders that are supposed to kick in late.
if (this.postTemplateLoaders != null) {
templateLoaders.addAll(this.postTemplateLoaders);
}
TemplateLoader loader = getAggregateTemplateLoader(templateLoaders);
if (loader != null) {
config.setTemplateLoader(loader);
}
//config.setClassLoaderForTemplateLoading(classLoader, basePackagePath);
//config.setCustomAttribute(name, value);
//config.setDirectoryForTemplateLoading(dir);
//config.setServletContextForTemplateLoading(servletContext, path);
//config.setSharedVariable(name, value);
//config.setSharedVariable(name, tm);
config.setSharedVariable("fmXmlEscape", new XmlEscape());
config.setSharedVariable("fmHtmlEscape", new HtmlEscape());
//config.setSharedVaribles(map);
return config;
}
示例3: getWriter
import freemarker.template.TemplateModelException; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Writer getWriter(final Writer out, final Map args)
throws TemplateModelException, IOException {
final StringBuilder buf = new StringBuilder();
return new Writer(out) {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
buf.append(cbuf, off, len);
}
@Override
public void flush() throws IOException {
out.flush();
}
@Override
public void close() throws IOException {
try {
Environment env = FreeMarkerWorker.getCurrentEnvironment();
BeanModel req = (BeanModel) env.getVariable("request");
BeanModel res = (BeanModel) env.getVariable("response");
if (req != null) {
final String escapeAs = TransformUtil.getStringArg(args, "escapeAs"); // SCIPIO: new
boolean rawParamsDefault = UtilValidate.isNotEmpty(escapeAs) ? true : false; // SCIPIO: if we're post-escaping, we can assume we should get rawParams
boolean rawParams = TransformUtil.getBooleanArg(args, "rawParams", rawParamsDefault); // SCIPIO: new
boolean strictDefault = UtilValidate.isNotEmpty(escapeAs) ? true : false; // SCIPIO: if we're post-escaping, we can assume we want strict handling
final Boolean strict = TransformUtil.getBooleanArg(args, "strict", strictDefault); // SCIPIO: new
String contentId = TransformUtil.getStringArg(args, "contentId", rawParams);
String viewContent = TransformUtil.getStringArg(args, "viewContent", rawParams);
Boolean urlDecode = TransformUtil.getBooleanArg(args, "urlDecode");
HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
HttpServletResponse response = null;
if (res != null) {
response = (HttpServletResponse) res.getWrappedObject();
}
String url = "";
if (UtilValidate.isNotEmpty(contentId)) {
url = ContentUrlFilter.makeContentAltUrl(request, response, contentId, viewContent, urlDecode);
}
out.write(TransformUtil.escapeGeneratedUrl(url, escapeAs, strict, env));
}
} catch (TemplateModelException e) {
throw new IOException(e.getMessage());
}
}
};
}
示例4: getWriter
import freemarker.template.TemplateModelException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Writer getWriter(final Writer out, Map args) {
final StringBuilder buf = new StringBuilder();
final Double amount = OfbizAmountTransform.getAmount(args, "amount");
final String locale = OfbizAmountTransform.getArg(args, "locale");
final String format = OfbizAmountTransform.getArg(args, "format");
return new Writer(out) {
@Override
public void write(char cbuf[], int off, int len) {
buf.append(cbuf, off, len);
}
@Override
public void flush() throws IOException {
out.flush();
}
@Override
public void close() throws IOException {
try {
if (Debug.verboseOn()) Debug.logVerbose("parms: " + amount + " " + format + " " + locale, module);
Locale localeObj = null;
if (locale.length() < 1) {
// Load the locale from the session
Environment env = FreeMarkerWorker.getCurrentEnvironment();
BeanModel req = (BeanModel) env.getVariable("request");
if (req != null) {
HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
localeObj = UtilHttp.getLocale(request);
} else {
localeObj = env.getLocale();
}
} else {
localeObj = new Locale(locale);
}
if (format.equals(OfbizAmountTransform.SPELLED_OUT_FORMAT)) {
out.write(UtilFormatOut.formatSpelledOutAmount(amount.doubleValue(), localeObj));
} else {
out.write(UtilFormatOut.formatAmount(amount.doubleValue(), localeObj));
}
} catch (TemplateModelException e) {
throw new IOException(e.getMessage());
}
}
};
}
示例5: getWriter
import freemarker.template.TemplateModelException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Writer getWriter(final Writer out, Map args) throws TemplateModelException {
final StringBuilder buf = new StringBuilder();
final String escapeAs = TransformUtil.getStringArg(args, "escapeAs"); // SCIPIO: new
boolean rawParamsDefault = UtilValidate.isNotEmpty(escapeAs) ? true : false; // SCIPIO: if we're post-escaping, we can assume we should get rawParams
final boolean rawParams = TransformUtil.getBooleanArg(args, "rawParams", rawParamsDefault); // SCIPIO: new
boolean strictDefault = UtilValidate.isNotEmpty(escapeAs) ? true : false; // SCIPIO: if we're post-escaping, we can assume we want strict handling
final Boolean strict = TransformUtil.getBooleanArg(args, "strict", strictDefault); // SCIPIO: new
final String imgSize = TransformUtil.getStringArg(args, "variant", rawParams);
final String uri = TransformUtil.getStringArg(args, "uri", rawParams); // SCIPIO: uri as alternative to nested
final Boolean urlDecode = TransformUtil.getBooleanArg(args, "urlDecode"); // SCIPIO: new
final Object ctxPrefixObj = TransformUtil.getBooleanOrStringArg(args, "ctxPrefix", null, false, rawParams); // SCIPIO: new
// SCIPIO: autoVariant params: added 2017-08-08
final String autoVariant = TransformUtil.getStringNonEscapingArg(args, "autoVariant");
final Integer imgWidth = TransformUtil.getIntegerArg(args, "width");
final Integer imgHeight = TransformUtil.getIntegerArg(args, "height");
final String imgVariantCfg = TransformUtil.getStringNonEscapingArg(args, "variantCfg");
return new Writer(out) {
@Override
public void write(char cbuf[], int off, int len) {
buf.append(cbuf, off, len);
}
@Override
public void flush() throws IOException {
out.flush();
}
@Override
public void close() throws IOException {
try {
Environment env = FreeMarkerWorker.getCurrentEnvironment();
BeanModel req = (BeanModel)env.getVariable("request");
HttpServletRequest request = req == null ? null : (HttpServletRequest) req.getWrappedObject();
// SCIPIO: delegated to our new method
BeanModel resp = (BeanModel) env.getVariable("response");
HttpServletResponse response = (resp == null) ? null : (HttpServletResponse) resp.getWrappedObject();
String ctxPrefix = getContentPathPrefix(ctxPrefixObj, rawParams, env); // SCIPIO: new
String url = ContentRequestWorker.makeContentLink(request, response, UtilValidate.isNotEmpty(uri) ? uri : buf.toString(), imgSize, null,
ctxPrefix, urlDecode, strict, autoVariant, imgWidth, imgHeight, imgVariantCfg);
out.write(TransformUtil.escapeGeneratedUrl(url, escapeAs, strict, env));
} catch (TemplateModelException e) {
throw new IOException(e.getMessage());
}
}
};
}