Your SlideShare is downloading. ×
  • Like
×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Using velocity Templates(An overview)

  • 2,365 views
Published

A sample guide in implementing velocity templates in sending sms and email

A sample guide in implementing velocity templates in sending sms and email

Published in Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,365
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
21
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. A template engine is a software developmenttool that allows you to create and renderdocuments that format and present your data.A template engine is included as part ofa template system or applicationframeworkContent from a database and "presentationspecifications" (in a web template), arecombined (through the template engine) toproduce web documents.
  • 2.  Examples are: Engine Language Apache Velocity Java, C# ASP.net C#, VB.net Casper Java, Javascript String Template Java, Python Cheetah Template Python
  • 3.  Template engines generally include features common in higher level programming with emphasis on processing plain text Features include:  Variables and functions  Text replacement  File inclusion  Conditional evaluation and loops
  • 4. Velocity Template EngineIt permits the templates to reference methods defined in Javacode using Velocity template language(VTL) statements.VTL uses references to embed dynamic content in a textproductReferences are of three types variables, properties and Methods VTL REFERENCES Variable ${aVariable}, $aVariable Properties ${anIdentifier.aIdentifier} Methods ${aIdentifier.aMethodBody(${aIdentifier})}
  • 5. Variable #set($ aVariable = “aValue”)Character Value directive References begin with $ and are used to get something Directives begin with # and are used to do something #set is used to assign a value to a variable The variable, $aVariable can the be used in the template to output the value(i.e “aValue”)
  • 6. Lets Work!! Download velocity engine (Velocity-1.7 jar) from http://velocity.apache.org/download.cgi Include the Velocity-1.7 jar jar in the lib folder of your project folder(you may also have to include commons- collections.jar, commons-lang and mail.jar). Prepare your .vsl template message Write your java code
  • 7. Template Message#*Test E-mail Message@zed*#Dear Mr $recepientName, The management of $companyName hereby invite you for an interview in $interviewVenue at $timeOfInterview .Yours Sincerely,$sendersName
  • 8. Sample Codepublic void sendMail() {Template template = null;template = ve.getTemplate("/myMessage.vsl"); Map<String, String> mymail = new HashMap<String, String>(); mymail.put("recepientName", infoDetail.getRecepientname()); mymail.put("companyName", infoDetail.getCompanyName()); mymail.put("interviewVenue", infoDetail.getInterviewVenue()); mymail.put("timeOfInterview", infoDetail.getTimeOfInterview()); mymail.put("sendersName", infoDetail.getSenderName()); VelocityContext context = new VelocityContext(mymail); StringWriter writer = writer = new StringWriter(); if (template != null) { template.merge(context, writer); } message = writer.toString();}
  • 9. OutputDear Mr James, The management of Seamfix hereby invite you for an interview in Lagos at 8:00pmYours Sincerely,Zebrudaya
  • 10. QUESTIONS??