1 / 8

Velocity Templates

Velocity Templates. Site Support Team Office of Operational Services May,23 2008. NOAA’s National Weather Service. NOAA’s National Weather Service. What is Velocity?. Velocity is a Java-based template engine.

reed-boyd
Download Presentation

Velocity Templates

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Velocity Templates Site Support Team Office of Operational Services May,23 2008 NOAA’s National Weather Service NOAA’s National Weather Service

  2. What is Velocity? • Velocity is a Java-based template engine. • Templates contain Text, Variables (references) and Velocity Template Language (VTL). • Text is output unchanged. • Variables can be Java Objects. • VTL is a scripting language.

  3. WarnGen GUI • The Warngen GUI is driven by: • config.xml • java code • <template>.cfg files. • The <template>.cfg files control many parameters about warnings <template>.cfg Values in GUI

  4. WarnGen Templates • The Warngen Templates are the <template>.vm files • The <template>.vm files are processed when “CREATE TEXT” button is pressed. • The Velocity Engine inserts the variables and processes the logic in the templates. • The result is a text warning product.

  5. Simple Template • THIS IS A TEST • #set( $office = "MANHATTAN, KANSAS" ) • THE NATIONAL WEATHER SERVICE IN $office HAS DONE NOTHING. The VLT command sets the variable $office which is then replaced into subsequent instances of the variable The output : THIS IS A TEST THE NATIONAL WEATHER SERVICE IN MANHATTAN, KANSAS HAS DONE NOTHING.

  6. Tricky Template • ${officeLong} HAS ISSUED A • * ${testMessage}TORNADO WARNING FOR... • #foreach (${area} in ${areas}) • ## • #if(${area.partOfArea}) • #areaFormat(${area.partOfArea} 0) ## • #end $officeLong is a variable from a config.xml file $testMessage comes from the GUI settings $Areas is an array of JAVA area objects from the code #areaFormat is a VTL Macro ( in VM_global_library) ${area.partOfArea} is a method in the JAVA area object

  7. Warngen loaded with Values from Config.xml Launch Warngen <template>.cfg Read <te,mplate>.cfg file Default Parameters Set from <template>.cfg file Set Warning Polygon and storm track GeoSpatiial Data Generated From Polygon Drawn on screen Java Objects, VTL Code and Text processed by velocity engine Select Create Text Button <template>.vm Edit Window Launched with product Prodcut Loads into Text Editor

  8. References • Velocity Template User Guide • Velocity Reference Guide • Velocity VTL Reference • Velocity Examples Document • http://www.nws.noaa.gov/ost/SEC/AE/Site_Migration.htm

More Related