freemarker

Struts2 debug tag thinks toString() is udefined

Debug tag in Struts2 keeps getting this error. Any ideas what could cause this? FreeMarker template error! Expression stackObject.value.get(propertyName).toString() is undefined on line 58, column 122 in template/simple/debug.ftl. The problematic instruction: ---------- ==> ${stackObject.value.get(propertyName).toString()?html} [on ...

Do I have access to annotations through freemarker?

I am rendering a form to present an annotated domain model class, i.e.: @Entity class User { @NotNull private String name; // other code } I would like to read the annotated meta-data to decide how to render each property. I would use it to add css classes to my input tags and finally use jQuery to attach validation metho...

How to get a random integer in Freemarker template?

Is it possible to generate a random integer in Freemarker template? ...

freemarker, parse values from template

Is it possible to make next using freemarker? e.g. in template i specify some values (i hope my syntax isn't misleading): <td>${{<img src="[1234:thumb]" /><img src="[3456:thumb]" />}?{images are missing}}</td> Idea is that, if application can make value, then new value used in template, if can't - default value is used. Main point is...

What are the main differences between StringTemplate and FreeMarker?

The net seems to be full of comparisons between Velocity and FreeMarker, and they seem to be reasonably equivalent. But there seems to be almost no comparisons between StringTemplate and FreeMarker! So, what are the main differences between StringTemplate and FreeMarker? My usage for them would be to generate HTML pages only. Out of th...

How should I initialize class freemarker.template.Configuration?

Attempting to follow this Java tutorial. About 63 pages in, you are instructed how to create a form ("New.jsp") to submit new events. When I try to visit the page, I get the following error: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this...

A url resource that is a dot (%2E)

I have a resource that is a . This means my url looks like this: http://myapp/index/. And i need to add query parameters so that it looks like this: http://myapp/index/.?type=xml I use Freemarker for the presentation of my resources and made a percent-encoding hack for this case: <#if key?matches("\\.")> <li><a href="${contextPath}/inde...

How can I get data from a Freemarker template into GWT code?

I have a webapp setup that uses Stripes and Freemarker; for part of it I'm also coding some GWT stuff, and I'm trying to figure out the best way of getting information from the actionBean into GWT code. Currently I do this in the template: <script> var params = { nick : "${actionBean.nick}", logout: "${actionBean.logout}" } ...

Freemarker assign list length to local variable

The following freemarker code causes an exception <#assign i= it.getList().size()> <#list it.getList() as elem> <#if i==1> <li>${elem.name}</li> <#else> <li class="marked">${elem.name}</li> </#if> <#assign i = i-1> </#list> The following exception is thrown: Expected hash. it.getList() evaluated instead to ...

howto display validation errors in freemarker template

Hello, all approches i do to display my validation errors in a freemarker template fail. i use spring mvc version 3. My form looks like that <@layout.basic> <@spring.bind "user" /> <#if spring.status.error> <div class="errors"> There were problems with the data you entered: <ul> <#list spring.status.err...

How do I use a template code generator (eg freemarker) in Maven?

How would you structure Freemarker (or an alternative) as a templating code generator into a Maven project? I'm pretty new to Maven and would appreciate some help. I want to generate some code from templates in my project. [a] Rather than write my own, googling found freemarker which appears to be used by Spring which is a good enough...

FreeMarker cannot seem to parse HTML 5 data-* atttributes

I wrote a simple custom directive, and have it pass all attributes through as regular element attributes. The syntax of the tag as follows: <@link_to controller="unobtrusive" action="do-get" data-target="result">Do Get</@> Unfortunately, I get an exception: Caused by: freemarker.core.ParseException: Encountered "-" at line 32, colu...

How can I use freemarker variable inside JSP tag?

I would like to use variable calculated in freemarker inside Struts tag. How can I do this in following situation: <#assign val0=100 /> <#assign val1=1000 /> <@s.select value="amount" name="amount" label="Amount" id="amount" list=r"%{#{val0:'text100', val1:'text1000'}}"/> Currently this select is empty. ...

Getting template text from FreeMarker in Struts2 app

I would like to generate email inside a Struts2 application, using Freemarker. As I am also using Freemarker for my view, I would like to "reuse" the same config. There is already a similar question for doing the same thing with Spring. http://stackoverflow.com/questions/230763/getting-template-text-from-freemarker-in-spring-app I am n...

FreeMarker cannot seem to parse HTML 5 data-* atttributes, chokes on dash

I wrote a simple custom directive, and have it pass all attributes through as regular element attributes. The syntax of the tag as follows: <@link_to controller="unobtrusive" action="do-get" data-target="result">Do Get Unfortunately, I get an exception: Caused by: freemarker.core.ParseException: Encountered "-" at line 32, column 5...

Freemarker 'Collection.contains' functionality

From my java code I'm returning a Set<String>. The view needs to check if the Set contains a specific string.. I can't find any docs on how Freemarker can handle this. Any idea? ...

Format freemarker files in Eclipse

Hi, Actually we have freemarker files (ftl) under Eclipse + Freemarker plugin (from JBoss). Do you know a way to format ftl files ? Thanks ...