freemarker

Keycloak's FreeMarker email template

强颜欢笑 提交于 2019-12-24 05:11:03
问题 I'm using Keycloak to send a forgot password email, and from what I've read on their docs and the FreeMarker docs, it seems like I should be able to use HTML tags just fine. However, when I use them in the password-rest.ftl file, it renders the whole tag like so: <p>Some Text</p> instead of just showing: Some Text I found this (https://issues.jboss.org/browse/KEYCLOAK-681) saying that Keycloak can only send plain text emails, and I just wanted to see if anyone knew for sure since I have found

Not able to read Object values in Freemarker Template

大兔子大兔子 提交于 2019-12-24 00:36:16
问题 I am naot able to read the scala/java object values in Freemarker Templet I tried with this: case class ScheduleEmail(workOrderNo:String, name:String, woType:String, numberOfAssets:String, artisan:String, dueDate:Date,priority:String) object ScheduleMailSending extends App{ val scheduleEmail1= List(ScheduleEmail("1", "Oil Change1", "WO", "3", "XYZ", Date.valueOf("2015-01-01"), "High")) val configaration = new Configuration configaration.setClassForTemplateLoading(this.getClass, "/")

`name` as a variable name in freemarker breaks

假如想象 提交于 2019-12-23 22:30:33
问题 I have the following code in an ftl: <#macro field label name value="" type="text"> ${name} ${name!"print if null"} <div class="field"> <div class="clearfix" id="${name}_field"> <label for="${name}">${label}</label> <div class="input"> <input type="${type}" id="${name}" name="${name}" value="${value}"> <span class="help-inline"></span> <span class="help-block"></span> </div> </div> </div> </#macro> <@field label="label" name="test" /> And this is printing this: foo-test test <div class="field

Load a resource in Jar

回眸只為那壹抹淺笑 提交于 2019-12-23 17:02:20
问题 Below is structure of my Jar file root - template.ftl - org.project.myproject.App.java Inside App.java, I have a line of code that expects me to specify the directory for loading the template.ftl . Something like: Line#1: cfg.setDirectoryForTemplateLoading("java.io.File object that represents /directory/for/storing/template/files"); and the next line of code, read the template file Line#2: Template temp = cfg.getTemplate("template.ftl"); My problem is that I'm not able to specify the path of

Spring Boot搭建Web项目要点

随声附和 提交于 2019-12-23 16:25:00
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 搭建WEB项目过程中,哪些点需要注意: 1、技术选型: 前端:freemarker、vue 后端:spring boot、spring mvc 2、如何包装返回统一结构结果数据? 首先要弄清楚为什么要包装统一结构结果数据,这是因为当任意的ajax请求超时或者越权操作时,系统能返回统一的错误信息给到前端,前端通过封装统一的ajax请求统一处理这类错误信息(这样统一就避免每次都需要额外处理)。 那如何包装结构呢? 先封装统一返回结果结构对象 JsonMessage: public class JsonMessage extends HashMap<String, Object> { private static final long serialVersionUID = -7149712196874923440L; public JsonMessage() { this.put("status", 200); } public JsonMessage(boolean status) { putStatus(status); } public JsonMessage(String msg) { this.put("status", 200); this.put("msg", msg); } public

Invoke Java method with parameters from Freemarker

删除回忆录丶 提交于 2019-12-23 10:57:47
问题 The following FTL markup works fine for me and calls getWidgets() in my server-side JiveActionSupport object: <#list widgets! as widget> -- do something with widget.sku </#list> However, I really need an inner list that depends on a property of widget, something like this: <#list widgets! as widget> <#list manufacturers(widget.sku)! as manufacturer> -- do something with manufacturer </#list> </#list> I have tried to implement the server-side code, as either: public List<Manufacturer>

What is the function of the @EnableWebFlux annotation

旧街凉风 提交于 2019-12-23 09:46:50
问题 I have a very simple webflux demo application with freemarker which has got following files: 1.WebFluxDemoApplication.java @SpringBootApplication public class WebFluxDemoApplication { public static void main(String[] args) { SpringApplication.run(WebFluxDemoApplication.class, args); } @Controller class HomeController { @GetMapping("/hello") public String hello() { return "index"; } } } 2.index.ftl (located under classpath:/templates) <html> <head> <title>demo</title> </head> <body></body> <

FreeMarker - Get Current URL

你。 提交于 2019-12-23 07:27:34
问题 Is it possible to get the current page's URL in FTL? 回答1: As far as I can tell, freemarker is strictly a templating engine -- it simply produces text, and has no way of knowing where that text will appear. If you want to include the "current page's URL", you'll either have to pass that data into the template from the host Java code (recommended) or you'll have to detect it client-side using javascript. 回答2: I'm running Spring 3.2.x and exposeSpringMacroHelpers defaults to true. As per Spring

Convert string to JSON in Freemarker

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 02:38:56
问题 Any ways on how we can convert VALID JSON STRING to actual JSON(sequence) in freemarker . I mean this string is actually returned by a JSON.stringify() call. I follow what this post says but it seems this is not applicable to mine. <#assign test = "(record.custpage_lineitems?json_string)"> <#assign m = test?eval> <#list m as k> ${k.item} </#list> ERROR says Expected collection or sequence. m evaluated instead to freemarker.template.SimpleScalar on line 286, column 32 in template. Sample JSON

Handling FreeMaker template with Ktor Kotlin

别来无恙 提交于 2019-12-22 21:53:33
问题 I'm very new to Kotlin (and Java), as well as Ktor and FreeMaker , trying to make an app combining all of them, but looks I'm doing something wrong related to the FreeMaker templates manipulating. My app structure is: template.ftl : <#macro mainLayout title="Welcome"> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>${title} | Kweet</title> </head> <body> HI </body> </html> </#macro> index.ftl : <#import "template.ftl" as layout />