Dec 2nd, 2008, 01:08 AM
Mailing in Spring Framework
I am creating a small web app which sends out mail for marketers, so I have created beans the application content, which have different mail factories .For respective mail factory we have templates. Now my requirement is to change the content of the templates dynamically as well as storing that HTML template at a location so that my server can pick it up which I send my for that marketer guy.
Please let me know if you guys have any thoughts or ideas on this.
Dec 2nd, 2008, 02:04 AM
Could you elaborate a bit more? I am unable to understand especially the following sentence:
Originally Posted by jaistage
Dec 2nd, 2008, 02:19 AM
I mean that my mail templates are stored in a folder in my tomcat, if I change that email template from a JSP page (the contents in the template) how would they be written in that file in the tomcat.
I want to say that my templates are kept at a location outside my normal WAR, is there a way to update these templates on the server through the web ???
Dec 2nd, 2008, 04:38 AM
Don't know if this helps:
We are using freemarker for the view layer and thus for all templates.
The templates are stored localized in the classpath.
We welcome you at ....
Please click the link below to activate your account
// contains the tokens
Map<String, String> model = new HashMap<String, String>();
// our model should now about
The main code to fetch the replace the tokens in the template looks like:
msg = FreeMarkerTemplateUtils.processTemplateIntoString( mailTemplateEngine.getTemplate(EMAIL_CONFIRMATION_ TEMPLATE,locale,ENCODING_DEFAULT,true) ,model);
This way freemarker picks up a template from the classpath, parses it and replaces the tokens by the params
does this help ???
Dec 2nd, 2008, 08:55 AM
It sounds like the poster wants to give clients the ability to modify the templates on-the-fly via a web interface.
Certainly a java class can save text to a file anywhere on the file system; it need not be within the web path. So one option is to load up the template contents into a JSP, edit them, and save using a FileWriter or some such. Note that you can't save just the changes -- you have to delete and save the whole thing.
Another option (the one we have chosen to use) is to put the templates into a database. We're using Velocity and you can use VelocityEngine.evaluate to do the template substitution with any string (such as a template string retrieved from a database). Happy to post code if you need.
Dec 4th, 2008, 02:39 PM
This sounds reasonable. I think I'd have a funny feeling in my stomach letting the (web-)app write "anywhere" in the filesystem.
Originally Posted by jacobmattison
Dec 8th, 2008, 08:28 AM
Thanks a lot Jacob,
I am looking into the way you have mentioned will let you know soon.
Tags for this Thread