freemarker

Spring MVC: RESTful URLs + Freemarker + Tiles + Spring macros - can these work together?

Hi guys, I want to use RESTful URLs in Spring MVC 3.0.3, e.g. the following in my web.xml: <servlet> <servlet-name>addictedWebServices</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>addictedW...

Freemarker checkboxex selection to be put on jbpm4 contex

Using JBPM and Freemarker... I need to put on the jbpm context the list of checkboxex that a user selects in a .ftl page. My code looks like: <table border="0"> <#list keyNames as key> <tr> <td><input type="checkbox" name="selectedKeys" value=${key} /></td> <td>${key}</td> ...

Spring MVC + FreeMarker: How to render option tag?

Hi there, The Spring 3 MVC docs state that option tags can be rendered like this: <tr> <td>Country:</td> <td> <form:select path="country"> <form:options items="${countryList}" itemValue="code" itemLabel="name"/> </form:select> </td> </tr> I am using FreeMarker with Spring MVC, so I ...

Freemarker doesn't see standart tag libraries in Struts2 project

I am currently upgrading our web application from Webwork to Struts2. I run to problem with freemarker that I am unable to resolve. In FTL file I have: <#assign c=JspTaglibs["http://java.sun.com/jstl/core"]> When rendering the page I get: JspTaglibs["http://java.sun.com/jstl/core"] is undefined. I use other taglibs (e.g. sprin...

[freemarker]howto avoid null when formatting value

${date?string('yyyy-MM-dd')} if date is null,freemarker will raise a exception here is a solution <#if date??>${date?string('yyyy-MM-dd')} but this code is ugly,is there any shortcut like ${date!} ? ...

Struts2 + Freemarker + DisplayTag: how to make it work

I am currently upgrading our application from Webwork to Struts2. Today I run into strange error: displayTag stopped working after the upgrade. This is a snipped from my FTL file: <#assign display=JspTaglibs["http://displaytag.sf.net"]> <@s.set name="entries" value="historyEntries" scope="page"/> <@display.table class="data" name="p...

Load objects before action, and share those objects in action and freemaker modules, possible?

Say a logged in user hits the url: www.example.com/forum/234 Before the spring mvc action fires, I want to load the User Object, the user's permission, the Forum object. Now I want to share these objects accross this request. So other classes can look to see, in the current request, for a User, Permission and Forum object. Potentia...

advice on freemarker templating, want to create a master template

I want to create a master template that every other view page will inherit. So the master template will have: HEADER --CONTENT-- FOOTER the header will optionally show (if the user is logged in), the username and other user object properties. the --CONTENT-- is a placeholder that other 'inheriting' view pages will inject their conte...

If I have a handler interceptor that loads a user object, adds it to request attri, do I cast to get object?

I plan to create a Handler interceptor that will fire before the controller gets called (or I'll do this pre-action firing). I will then check the user's cookie, and load the user object based on the sessionid in the cookie. I will then add the user object to the request attributes. Now if I want to retrieve the user object in my cont...

Getting comma inside value of long type at freemarker page

I am having some strange problem and its really frustating me. I have a list of Car bean in request attribute - List<Car> cars = myservice.getCars(); request.setAttribute("cars", cars); When I print the car ids (long type), it gives me correct value - for(Car car: cars) { System.out.println(car.id); } // It gives me - 11231, 11245, ...

Using JAX-RS / Jersey with Freemarker templates

There are examples on the web showing how to use the JAX-RS implementation Jersey with custom template engines like FreeMarker. But these examples are looking a bit improvised or dated. There is also one example relying only on JAX-RS and not Jersy specific classes. Is there a mature ViewProcessor implementation for FreeMarker or do I ha...

Limit string length in FreeMarker

Hi, I'm trying to get a substring from a string in FreeMarker. However there are 2 thigns to consider: The string can be null The string can be shorter then the maximum string length I do the following: <#list landingpage1.popularItems as row> <li> <span class="minititle"> <#assign minititle=(row.title!"")> ...

FreeMarker encoding confusion

When I read an UTF-8 encoded template with FreeMarker, special chars are rendered correctly in the browser, although freeMarkerConfig.getDefaultEncoding() returns "Cp1252". If I set freeMarkerConfig.setDefaultEncoding("UTF-8"), I see only question marks in the browser, although "UTF-8" is the actual encoding of the template file. In ever...

Logging missing variables in FreeMarker

Does anyone know how to list the variables that are missing from the data model of a FreeMarker template? I am trying to give some nice information to the user, such as: "template defines field "foo" but no data was provided" ...

Accessing Map elements via Enum key in Freemarker

Hi all, I'm trying to access elements in a HashMap. The keys of this HashMap are defined by an Enum. After going through the documentation, I figured that in order to be able to access the Enum, I have to send it to Freemarker like so: BeansWrapper wrapper = BeansWrapper.getDefaultInstance(); TemplateHashModel enumModels = wrapper.get...

Freemarker or JSP ?

which one is better? i want to make web based application , new to Java world but not to the programming..... ...

Does spring.ftl (freemarker bindings) support nested paths? How?

How can I write the freemarker templates like this: <#import "spring.ftl" as s> <@s.form path="object" action="/new.do" method="POST"> <@s.formInput "name"/> <!-- I want this resolved as "object.name" --> <!-- 100s of other properties... --> </@s.form> instead of this: <#import "spring.ftl" as s> <form action=...

How can I push a variable on the value stack in freemarker

In freemarker, I'm looking to include an existing template from within another repetitively. The existing template assumes it's looking at the top of the value stack. I'm really looking for an 'apply' function. So I have a parent template: <#list items as item> <#include "/my/subtemplate.ftl"/> </#list> How can I make the subtemplate ...

Prevent FreeMarker to wrap a class implementing Collection in SimpleSequence

I have a Page class implementing java.util.Collection as well as other methods like hasPreviousPage, getTotalPages, etc. Freemarker wraps this class in a SimpleSequence, preventing me to access such methods. i.e. when I write ${page.getTotalPages()} I got this error: Expected hash. myPage evaluated instead to freemarker.template.Simple...

How to change name of Hibernate Tools reverse engineerd DAO class?

Hi, So im trying to use Hibernate Tools to reverse engineer my database and I am just getting into using Freemarker templates to weak the code it generates. The problem is I want to change the name of the DAO classes it generates. By default the DAO classes are named in the form PersonHome however to change the name to PersonDAO i modif...