
Velocity Templates with Java Calls - Tradeoffs | ModelPro
This topic explores the tradeoffs involved where Velocity Templates within a cartridge become complex enough to warrant calling out to Java. Apache Velocity is an open source software project directed by the Apache Software Foundation. Velocity is a Java-based template engine that provides a simple yet powerful template language and is becoming popular for use both at build-time and run-time. While particularly powerfull within the general context of template processing, Velocity is not a full-featured language, and some tasks can be extreemly cumbersome. For instance simple alphanumeric string processing tasks such as capitalization related routines seem to be far more effectively implemented in pure Java. Velocity and the ModelPro template binding infrastructure provide a means of declaring variables in a binding specification which can be used "in-line" within Velocity based templates or Velocity Macros. As the number of such utilities grows within a large cartridge project, how do we keep a clean seperation between the types of utilities such that they are easily understood, maintained and re-used within other projects? Are there restrictions to which such utilities must adhere? What are the basic categories of such utilities?

rss


integration
I don't see there being an easy way to incorporate both Java and Adobe. They both have entirely different layouts. You can conduct all of the multivariate testing you want, but you still won't find a way to make these two work together. Then again this is comming from a newbie programer. (I only dabble) Maybe this sounds like mindless dribble to some, and if it does. Tell me why exactly, I would love to know :)
1
thanks for sharing nice info
blower
camper
diablo
dispenser
flaps
I think using the profile
I think using the profile directly is a good way to start because once you download the SOA+ evaluation copy, you'll realize how much easier it is to model.
I couldn't agree more
I totally agree with your insights. Thanks for sharing.
Matt Proman - Matthew Proman
New
As a research paper writer I totally understand what you mean
break example
See http://velocity.apache.org/engine/releases/velocity-1.6.2/user-guide.html.
## list first 5 customers only
#foreach( $customer in $customerList )
#if( $velocityCount > 5 )
#break
#end
$customer.Name
#end
Java "call-out" categories
Here's an initial list of rough categories where Java call outs from Velocity make sense.
1.) String Manipulation
2.) Sorting
3.) Type Checking and Conversion
4.) Package Name Checking and Manipulation
agree
Ya that kind of limitation is what gives rise to pushing code into Java. But you can at least check and set various directives related to iteration. See:
http://velocity.apache.org/engine/devel/user-guide.html#Loops
Velocity iteration
Hi; I'm working on a custom cartridge and am studying up on Velocity. The iteration cabability looks extreemly limited. For instance there is a #foreach but no #while loop, and how do you break out of a loop??