jstrachan 2002/06/14 03:55:31
Modified: jelly/src/test/org/apache/commons/jelly
show_properties.jelly
jelly/src/java/org/apache/commons/jelly JellyContext.java
jelly build.xml
Log:
Provided a default 'systemScope' variable by default in a JellyContext so that
System properties can be accessed easily.
Revision Changes Path
1.7 +3 -3
jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/show_properties.jelly
Index: show_properties.jelly
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/show_properties.jelly,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- show_properties.jelly 3 Jun 2002 05:14:29 -0000 1.6
+++ show_properties.jelly 14 Jun 2002 10:55:30 -0000 1.7
@@ -12,10 +12,10 @@
<th>Value</th>
</tr>
- <j:forEach var="iter" items="${System.getProperties()}">
+ <j:forEach var="iter" items="${systemScope}">
<tr>
- <td><j:expr value="${iter.key}"/></td>
- <td><j:expr value="${iter.value}"/></td>
+ <td>${iter.key}</td>
+ <td>${iter.value}</td>
</tr>
</j:forEach>
</table>
1.12 +8 -2
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java
Index: JellyContext.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- JellyContext.java 13 Jun 2002 21:31:14 -0000 1.11
+++ JellyContext.java 14 Jun 2002 10:55:31 -0000 1.12
@@ -121,6 +121,7 @@
public JellyContext() {
this.currentURL = rootURL;
+ init();
}
public JellyContext(URL rootURL) {
@@ -130,7 +131,7 @@
public JellyContext(URL rootURL, URL currentURL) {
this.rootURL = rootURL;
this.currentURL = currentURL;
- this.variables.put("context", this);
+ init();
}
public JellyContext(JellyContext parent) {
@@ -139,13 +140,18 @@
this.currentURL = parent.currentURL;
this.taglibs = parent.taglibs;
this.variables.put("parentScope", parent.variables);
- this.variables.put("context", this);
+ init();
}
public JellyContext(JellyContext parentJellyContext, URL currentURL) {
this(parentJellyContext);
this.currentURL = currentURL;
}
+
+ private void init() {
+ variables.put("context", this);
+ variables.put("systemScope", System.getProperties());
+ }
/**
* @return the parent context for this context
1.48 +7 -0 jakarta-commons-sandbox/jelly/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- build.xml 14 Jun 2002 10:24:14 -0000 1.47
+++ build.xml 14 Jun 2002 10:55:31 -0000 1.48
@@ -259,6 +259,13 @@
</target>
+ <target name="demo.sysprop" depends="compile"
+ description="Runs the system properties demo">
+
+ <jelly file="src/test/org/apache/commons/jelly/show_properties.jelly"
output="target/sysprop.html"/>
+
+ </target>
+
<target name="demo.ant" depends="compile"
description="Runs demo which displays Ant properties">
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>