ReportcardExamplepublic class ReportcardExample extends Object Include a table of the Values in DateFormatUtils |
Fields Summary |
---|
private static Logger | logger |
Methods Summary |
---|
public static void | main(java.lang.String[] pArg)
LogInit.init();
ReportcardExample test = new ReportcardExample();
test.testSimpleTemplate();
| private Results | testResults()
Results res = new Results();
int[] scores = {
40, 87, 95, 97, 75
};
res.setScores(scores);
Student s1 = new Student();
s1.setName("Tim O.");
s1.setScore(40);
Student s2 = new Student();
s2.setName("Susan P.");
s2.setScore(87);
Student s3 = new Student();
s3.setName("Rock P.");
s3.setScore(95);
Student s4 = new Student();
s4.setName("Stephanie P.");
s4.setScore(97);
Student s5 = new Student();
s5.setName("Federico H.");
s5.setScore(75);
Student[] sArray = {
s1, s2, s3, s4, s5
};
res.setStudents(sArray);
return res;
| public void | testSimpleTemplate()
VelocityEngine vEngine = new VelocityEngine();
vEngine.setProperty(
"velocimacro.library",
"scripting/velocity/extend/VM_students.vm");
vEngine.setProperty("resource.loader", "class");
vEngine.setProperty(
"class.resource.loader.description",
"Classpath Loader");
vEngine.setProperty(
"class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
vEngine.init();
VelocityContext context = new VelocityContext();
context.put("results", testResults());
context.put("stat", new StatUtil());
StringWriter writer = new StringWriter();
vEngine.mergeTemplate(
"com/discursive/jccook/script/velocity/extend/results.vm",
context,
writer);
logger.debug("results: " + writer.toString());
|
|