• 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

Configuring FreeMarker(.ftl) with Struts 2

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to configure FreeMarker(.ftl) with an application which is using Struts 2 (for views and actions) and Spring (for dependency injections).
I want to keep the template files (.ftl) in the application root folder. I am however not able to achieve.

The FreeMarker documention says that to make the template available to the application we need to place the template in either of these locations:
1. Classpath
2. Application root

With classpath it works fine for me but my requirement is different. Now to achieve this is tried to configure FreeMarker for struts/spring by telling the container the path where the template files are present. The following are the approaches:

STRUTS web.xml file


In SPRING's application-context.xml


However, both the approaches are not working. Am I missing something here ? Please help me out.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure I understood the problem you are having. If you are using freemarker for a custom struts 2 template.Have you set your struts.properties to specify that you are using the custom theme?The struts.properties will be something like this :
 
Kumar Sonu
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is true. I am using custom struts2 template but I have not set the properties. I will try setting the properties and try.
 
Kumar Sonu
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mars,
On another note could you also please suggest which of the approaches out of the ones I had mentioned (Struts/Spring) should be used ?
 
Kumar Sonu
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mars,
I tried setting the property, but I am facing the same problem.
The application does not pick up my customized ftl files but picks up the default Struts ftl files.

Note: I have modified the actionerror.ftl file to display error message in red background and as plain text. The default is to show in white backgound and as list item. I want the customized ftl to work.

The following is my current configurations:




Also note, the template directoty is placed in my root folder and not inside WEB-INF.

Please help.
 
Mars Mondal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Deepak,
Sorry for the late reply I got a little busy at work. Place your template folder inside the web-inf and see what happens. Also I see you have defined the properties in struts.xml file I think you should specify them in the struts.properties file. Try deleting those definitions from your struts.xml and then create another file called struts.properties. Copy paste what I sent you and see what happens. I will try and get you a screenshot of the folder structure to see for yourself.
Thanks,
Mars
 
Mars Mondal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To start the new theme you would make a template directory in your WEB-INF/classes directory, then in that one make a directory with the same name as your theme, in your case "css_xhtml". Then copy all of the files from the XHTML theme in the Struts 2 distribution intocss_xhtml to form the basis of your new theme. Again I will post you a screenshot of my computer from work tomorrow but try what I said first
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was facing the same issue described above and resolved it after getting the solution as described. However I upgraded the application to Struts 2.2.3.1 and the issue described above re-occurred again.
I am using the following version of freemarker library - 2.3.16

Can someone help me.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic