freemarker

How to access a Spring MVC model attribute name that contain a dot in Freemarker

会有一股神秘感。 提交于 2019-12-13 13:16:43
问题 I have the following code snippet in Spring MVC (3.0). @RequestMapping(value="/add", method = RequestMethod.POST) public String handleAddResourceGroup(@Valid ResourceGroup resourceGroup, BindingResult bindingResult, Model model) { if (bindingResult.hasErrors()) { model.addAttribute("flash.validationErrors", bindingResult.getAllErrors()); return "add"; } //The rest of the code } How can access the model attribute with the name "flash.validationErrors" in Freemarker? 回答1: Try ${.data_model[

Freemarker Error Expected hash?

廉价感情. 提交于 2019-12-13 08:39:14
问题 I want to transform a Instant time to Date but I'm getting this error: freemarker.template.TemplateException: Expected hash. newDate evaluated instead to freemarker.template.SimpleDate I'm doing this on Java: Date newDate = new Date(); Instant instant = Instant.now(); webContext.put("newDate",new Date()); webContext.put("instant",instant); And I'm doing this on Freemarker: [#assign dateFormated = newDate.getAsDate().from(instant.ofEpochSecond(data.time.seconds))/] Thank you 回答1: FreeMarker

How to call methods with enum parameter from freemarker

ⅰ亾dé卋堺 提交于 2019-12-13 07:47:30
问题 I want to customize Teamcity notification email with freemarker template. It's feasible to get Teamcity data model from freemarker. The data model is look like below <#-- @ftlvariable name="project" type="jetbrains.buildServer.serverSide.SProject" --> <#-- @ftlvariable name="buildType" type="jetbrains.buildServer.serverSide.SBuildType" --> <#-- @ftlvariable name="build" type="jetbrains.buildServer.serverSide.SBuild" --> <#-- @ftlvariable name="agentName" type="java.lang.String" --> <#--

FreeMarker Not Able Display Chinese Character

ε祈祈猫儿з 提交于 2019-12-13 06:43:48
问题 First time use FreeMarker on JAVA project and stack on configure the chinese character. I tried a lot of examples to fix the code like below, but it still not able to make it. // Free-marker configuration object Configuration conf = new Configuration(); conf.setTemplateLoader(new ClassTemplateLoader(getClass(), "/")); conf.setLocale(Locale.CHINA); conf.setDefaultEncoding("UTF-8"); // Load template from source folder Template template = conf.getTemplate(templatePath); template.setEncoding("UTF

cannot access list of object sent from modelmap in FTL file

£可爱£侵袭症+ 提交于 2019-12-13 06:11:28
问题 Im new to ftl(FreeMarker template). I send a List of object from my controller using model map like this My controller code @RequestMapping(value="/xxx") public String myMethod(ModelMap model){ List<MyDTO> dto = mymethods(); // I return some list objects in this method model.addAttribute("dto",dto); model.addAttribute("dtoLength",dto.size()); return "myview"; } MyDTO.java public class myDTO{ Public String var1; Public String var2; public String getVar1() { return var1; } public void setVar1

Validation and Freemarker

做~自己de王妃 提交于 2019-12-13 04:59:47
问题 We have to do validation on the page, in the case of empty fields to display a message. It's my class, the method of the controller and settings of messages. I can't to get on the page Freemarker display error messages. public class CreateCourseDTO { @NotEmpty private String name; @NotEmpty private String category; @NotEmpty private String description; @NotEmpty private String links; public CreateCourseDTO() { } NotEmpty.createCourseDTO.name = Name is required! NotEmpty.createCourseDTO

Where does Freemarker load templates in a maven generated jar

南笙酒味 提交于 2019-12-13 04:43:04
问题 Let me clarify my current practice. I have a maven project and the package architecture looks like below: src/main/java/com/gearon/app/App.java src/main/java/com/gearon/app/configuration/Config.java src/main/java/com/gearon/app/datamodel/*.java I tried to set directory where to load templates in Config.java with code below: cfg = new Configuration(); cfg.setClassForTemplateLoading(Config.class, "/templates"); cfg.setDefaultEncoding("UTF-8"); cfg.setTemplateExceptionHandler

Freemarker format BigDecimal to German Locale not working properly

拈花ヽ惹草 提交于 2019-12-13 03:55:04
问题 Following the documentation of FreeMarker : Using : <#setting number_format="0.##"> <#setting locale="hu"> German people write: ${12345678} Should output as shown in picture but instead what i get is the below : For input new BigDecimal(4436372342.10) => 4 436 372 342,10 which doesn't have . but instead has spaces . Why that happens ? 回答1: Seems like there is a documentation error. locale="hu" sets a Hungarian locale. Its thousands separator is ' ' . To set a German locale, try locale="de_DE"

How to use a FreeMarker template in a Magnolia App?

你说的曾经没有我的故事 提交于 2019-12-13 03:04:23
问题 I'm using Magnolia 5.4 and have developed an app following the documentation: https://documentation.magnolia-cms.com/display/DOCS54/Apps The app is being rendered correctly in the magnolia shell. Opening the app shows a «Hello World» message as described in the documentation: https://documentation.magnolia-cms.com/display/DOCS54/Programming+an+app#Programminganapp-MainSubApp I've removed the unnecessary code and ended up with this: public class HelloWorldMainSubAppViewImpl implements

Area attribute in xsl-fo external-graphic with coordinates

余生长醉 提交于 2019-12-13 02:33:06
问题 I have a requirement where I need to portray an image using xsl-fo and the user should be able to click within the text / particular location of the image. To explain it further, I have an image It contains text I have the co-ordinates of where the text occurs and need to provide hyper-link for those co-ordinates. So, when I click on the text, I should be able to traverse to another location in the PDF document. I have tried with <area> tag mentioning the co-ordinates within <fo:block> , but