• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Processing struts2 tags in freemarker templates

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a requirement to process freemarker ftl file on server side and return back the HTML to the client. I would like to know if it is possible to process freemaker template having struts tags in it using template.process().

Action class code

// Configuration created from struts2 freemarkermanager FreemarkerManager freeMarkerManager = new FreemarkerManager(); Configuration config = freeMarkerManager.getConfiguration(context);

//Configuration without any specific settings. Configuration config = new Configuration(); //Tried both nothing works.

Template template = config.getTemplate("TEMPLATE PATH");

Map<String, Object> inputMap = new HashMap<String, Object>(); inputMap.put("document", document);

StringWriter output = new StringWriter(); template.process(inputMap, output);

Freemarker template: <#assign s=JspTaglibs["/struts-tags"]> <table> <tr> <th><@s.text name="Document Name"/></th> <th><@s.text name="Description"/></th> </tr>

`<@s.iterator value="inspiration" status="status">`
`<tr>`
`<td class="nowrap"><@s.property value="properties.DOCUMENT_NAME"/></td>`
`<td class="nowrap"><@s.property value="properties.DESCRIPTION"/></td>`
`</tr>`
`</@s.iterator>`
`</table>`
I have also added struts-tags.tld under web-inf folder.

Exception

freemarker.core.InvalidReferenceException: Expression JspTaglibs is undefined on line 1,

If I remove <#assign s=JspTaglibs["/struts-tags"]>

freemarker.core.InvalidReferenceException: Expression s is undefined on line 7

Thanks in advance, Chethan
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic