Author: dishara
Date: Sun Aug 19 16:51:28 2012
New Revision: 1374791
URL: http://svn.apache.org/viewvc?rev=1374791&view=rev
Log:
Added some formatting
Modified:
velocity/sandbox/jsr223/src/site/xdoc/script-api-guide.xml
Modified: velocity/sandbox/jsr223/src/site/xdoc/script-api-guide.xml
URL:
http://svn.apache.org/viewvc/velocity/sandbox/jsr223/src/site/xdoc/script-api-guide.xml?rev=1374791&r1=1374790&r2=1374791&view=diff
==============================================================================
--- velocity/sandbox/jsr223/src/site/xdoc/script-api-guide.xml (original)
+++ velocity/sandbox/jsr223/src/site/xdoc/script-api-guide.xml Sun Aug 19
16:51:28 2012
@@ -1,4 +1,3 @@
-
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
@@ -43,49 +42,56 @@
</p>
<p>
- 1. ScriptEngineManager manager = new ScriptEngineManager();
+ <ul>1. ScriptEngineManager manager = new
ScriptEngineManager();</ul>
- 2. manager.registerEngineName("velocity", new
VelocityScriptEngineFactory());
+ <ul>2. manager.registerEngineName("velocity", new
VelocityScriptEngineFactory());</ul>
- 3. ScriptEngine engine =
manager.getEngineByName("velocity");
+ <ul>3. ScriptEngine engine =
manager.getEngineByName("velocity");</ul>
- 4.
System.setProperty(VelocityScriptEngine.VELOCITY_PROPERTIES, PROP_PATH) ;
+ <ul>4.
System.setProperty(VelocityScriptEngine.VELOCITY_PROPERTIES, PROP_PATH) ;</ul>
- 5. String script = "ADD_YOUR_SIMPLE_VELOCITY_SCRIPT";
+ <ul>5. String script =
"ADD_YOUR_SIMPLE_VELOCITY_SCRIPT";</ul>
- 6. Writer writer = new StringWriter();
+ <ul>6. Writer writer = new StringWriter();</ul>
- 7. engine.getContext().setWriter(writer);
+ <ul>7. engine.getContext().setWriter(writer);</ul>
- 8. Object result = engine.eval(script);
+ <ul>8. Object result = engine.eval(script);</ul>
- 9. System.out.println(writer);
+ <ul>9. System.out.println(writer);</ul>
</p>
<p>Description: against line number</p>
<p>
- L-1. First we need to obtain the script engine manager
-
- L-2. Lets register a engine with a vanilla velocity
scripting engine factory. Hence we use the
- default
- constructor to instantiate the factory. If want we can
pass a customized factory instance. For this
- example we are fine with the default settings.
-
- L-3. We can obtain the registered engine through manager.
-
- L-4. Set system property whose value will be the path to
the properties file used normally when
- creating a VelocityEngine.
+ <ul>L-1. First we need to obtain the script engine
manager</ul>
- L-5. The script that is need to evaluate
-
- L-6,7. Create your own writer and set it to the context so
that you can use that to view the final
- output.
- Similar manner you can obtain an error writer and see the
exceptions occurred.
-
- L-8. And finally evaluate the script itself. And the
result return will be a boolean which indicates
- the successfulness of the operation.
+ <ul>L-2. Lets register a engine with a vanilla velocity
scripting engine factory. Hence we use the
+ default
+ constructor to instantiate the factory. If want we can
pass a customized factory instance. For
+ this
+ example we are fine with the default settings.
+ </ul>
+
+ <ul>L-3. We can obtain the registered engine through
manager.</ul>
+
+ <ul>L-4. Set system property whose value will be the path
to the properties file used normally when
+ creating a VelocityEngine.
+ </ul>
+
+ <ul>L-5. The script that is need to evaluate</ul>
+
+ <ul>L-6,7. Create your own writer and set it to the
context so that you can use that to view the
+ final
+ output.
+ Similar manner you can obtain an error writer and see
the exceptions occurred.
+ </ul>
+
+ <ul>L-8. And finally evaluate the script itself. And the
result return will be a boolean which
+ indicates
+ the successfulness of the operation.
+ </ul>
</p>
@@ -97,51 +103,64 @@
</p>
<p>
- 1. ScriptContext context = engine.getContext();
+ <ul>1. ScriptContext context = engine.getContext();</ul>
+
+ <ul>2. Properties properties = new Properties();</ul>
+ <ul>3. properties.put("resource.loader", "class");</ul>
+ <ul>4. properties.put("class.resource.loader.description",
"Template Class Loader");</ul>
+ <ul>5.
+
properties.put("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+ </ul>
+
+ <ul>6.
+
context.setAttribute(VelocityScriptEngine.VELOCITY_PROPERTIES,properties,ScriptContext.ENGINE_SCOPE);
+ </ul>
- 2. Properties properties = new Properties();
- 3. properties.put("resource.loader", "class");
- 4. properties.put("class.resource.loader.description",
"Template Class Loader");
- 5.
properties.put("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+ <ul>7. CustomEvent event = new CustomEvent("MyEvent");</ul>
- 6.
context.setAttribute(VelocityScriptEngine.VELOCITY_PROPERTIES,properties,ScriptContext.ENGINE_SCOPE);
-
- 7. CustomEvent event = new CustomEvent("MyEvent");
-
- 8.
context.getBindings(ScriptContext.ENGINE_SCOPE).put("event", event);
-
- 9. context.setAttribute(VelocityScriptEngine.FILENAME,
"eventtool.vm", ScriptContext.ENGINE_SCOPE);
-
- 10. Writer writer = new StringWriter();
-
- 11. context.setWriter(writer);
-
- 12. engine.eval("$event;\n" +
- "Event Created by $event.getName()\n" +
- "Event Created on $event.getDate()\n" +
- "Event ID is $event.getID()
- ");
-
- 13.System.out.println("####### Tools output #########\n" +
writer);
+ <ul>8.
context.getBindings(ScriptContext.ENGINE_SCOPE).put("event", event);</ul>
+
+ <ul>9. context.setAttribute(VelocityScriptEngine.FILENAME,
"eventtool.vm",
+ ScriptContext.ENGINE_SCOPE);
+ </ul>
+
+ <ul>10. Writer writer = new StringWriter();</ul>
+
+ <ul>11. context.setWriter(writer);</ul>
+
+ <ul>12. engine.eval("$event;\n" +
+ "Event Created by $event.getName()\n" +
+ "Event Created on $event.getDate()\n" +
+ "Event ID is $event.getID()
+ ");
+ </ul>
+
+ <ul>13.System.out.println("####### Tools output
#########\n" + writer);</ul>
</p>
<p>
- L-1. Lets assume we obtain the script engine as mentioned
above.
+ <ul>L-1. Lets assume we obtain the script engine as
mentioned above.</ul>
- L-2,3,4,5 We create required properties to use the
velocity tool and set them to the context.
+ <ul>L-2,3,4,5 We create required properties to use the
velocity tool and set them to the context.
+ </ul>
- L-6 We set the properties in the engine scope. If want we
can set it as global scope so that all
- others can see.
+ <ul>L-6 We set the properties in the engine scope. If want
we can set it as global scope so that all
+ others can see.
+ </ul>
- L-7,8 This is a plain old bean class which has attributes
of an event i.e name, ID, date and etc
+ <ul>L-7,8 This is a plain old bean class which has
attributes of an event i.e name, ID, date and etc
+ </ul>
- L-9 Here we must set the name of the vm file which is
passed as the script to evaluate, if we want
- cache the template(This is recommended for better
performance). Remember when you do so, you must
- put the eventtool.vm file in your class path.
+ <ul>L-9 Here we must set the name of the vm file which is
passed as the script to evaluate, if we
+ want
+ cache the template(This is recommended for better
performance). Remember when you do so, you
+ must
+ put the eventtool.vm file in your class path.
+ </ul>
- L-12. Evaluate the script itself.
+ <ul>L-12. Evaluate the script itself.</ul>
</p>
</subsection>
@@ -150,5 +169,3 @@
</body>
</document>
-
-