Changeset 1436
- Timestamp:
- 2010-02-16 09:06:52 (2 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/testPage.html (modified) (1 diff)
-
modules/kauri-jquery/src/test/kauri.util/testPage.html (modified) (1 diff)
-
universe/kauri-template/src/main/java/org/kauriproject/template/VariableBlock.java (modified) (4 diffs)
-
universe/kauri-template/src/test/resources/org/kauriproject/template/variable_from_src.xml (modified) (1 diff)
-
universe/kauri-template/src/test/resources/org/kauriproject/template/variable_from_src_result.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/testPage.html
r1221 r1436 6 6 7 7 <link rel="Stylesheet" media="screen" href="../../../../../kauri-jquery/src/test/qunit/testsuite.css" /> 8 <script type="text/javascript" src="../../../../../kauri-jquery/src/main/kauri/static/jquery/jquery-1. 3.2/jquery-1.3.2.js"></script>8 <script type="text/javascript" src="../../../../../kauri-jquery/src/main/kauri/static/jquery/jquery-1.4.1/jquery-1.4.1.js"></script> 9 9 <script type="text/javascript" src="../../../../../kauri-jquery/src/test/qunit/testrunner.js"></script> 10 10 -
trunk/modules/kauri-jquery/src/test/kauri.util/testPage.html
r1182 r1436 5 5 <title>Kauri JQuery Main Test Page</title> 6 6 <link rel="Stylesheet" media="screen" href="../qunit/testsuite.css" /> 7 <script type="text/javascript" src="../../main/kauri/static/jquery/jquery-1. 3.2/jquery-1.3.2.js"></script>7 <script type="text/javascript" src="../../main/kauri/static/jquery/jquery-1.4.1/jquery-1.4.1.js"></script> 8 8 <script type="text/javascript" src="../qunit/testrunner.js"></script> 9 9 -
trunk/universe/kauri-template/src/main/java/org/kauriproject/template/VariableBlock.java
r1350 r1436 59 59 } 60 60 61 private static final Object NO_VALUE = new Object(); 62 61 63 class StartStep extends Step { 62 64 … … 101 103 } 102 104 105 103 106 @Override 104 107 public Step executeAndProceed(ExecutionContext context, TemplateResult result) throws SAXException { 105 108 TemplateContext tmplContext = context.getTemplateContext(); 106 109 if (overwrite || !tmplContext.containsKey(name)) { 110 Object value = NO_VALUE; 107 111 if (valueExpression != null) { 108 final Object value = valueExpression.evaluate(context.getTemplateContext()); 109 tmplContext.put(name, value); 110 } else if (srcExpression != null) { 111 Object data = loadFromSrc(context); 112 tmplContext.put(name, data); 112 value = valueExpression.evaluate(context.getTemplateContext()); 113 113 } else { 114 114 // use element body as value … … 123 123 buffer.endDocument(); 124 124 buffer.flush(); 125 String value;126 125 try { 127 126 bos.flush(); 128 value = bos.toString("UTF-8"); 127 final String content = bos.toString("UTF-8"); 128 if (content != null && content.length() > 0) 129 value = content; 129 130 } catch (IOException ex) { 130 131 throw new TemplateException("Error building variable value.", ex); 131 132 } 132 133 tmplContext.put(name, value); 134 } 135 } 133 } 134 135 // value retrieved from @value or body can be overwritten by loaded data from @src 136 if (srcExpression != null) { 137 value = loadFromSrc(context, value); 138 } 139 140 tmplContext.put(name, value); 141 } 142 136 143 return endStep.getCompiledNext(); 137 144 } 138 145 139 private Object loadFromSrc(ExecutionContext context ) {146 private Object loadFromSrc(ExecutionContext context, Object fallbackValue) { 140 147 String src = (String)srcExpression.evaluate(context.getTemplateContext()); 141 148 String accept = acceptExpression != null ? (String)acceptExpression.evaluate(context.getTemplateContext()) : null; … … 152 159 } 153 160 } catch (Throwable e) { 161 if (fallbackValue != NO_VALUE) 162 return fallbackValue; 163 // else 154 164 throw new TemplateException("Some error occured while loading data for variable " + name + " from URI " + src, e); 155 165 } finally { -
trunk/universe/kauri-template/src/test/resources/org/kauriproject/template/variable_from_src.xml
r1019 r1436 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <root xmlns:ktl="http://kauriproject.org/template"> 3 <ktl:variable name="data" src="data.json"/> 3 <ktl:variable name="data" src="data.json" value="ignore"/> 4 <ktl:variable name="data2" src="nodata.json" value="${data}"/> 4 5 <ktl:variable name="overwriteTest1" value="local"/> 5 6 <ktl:variable name="overwriteTest2" value="local" overwrite="false"/> 6 7 7 ${data.message},${ overwriteTest1},${overwriteTest2}8 ${data.message},${data2.message},${overwriteTest1},${overwriteTest2} 8 9 </root> -
trunk/universe/kauri-template/src/test/resources/org/kauriproject/template/variable_from_src_result.xml
r810 r1436 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <root xmlns:ktl="http://kauriproject.org/template"> 3 Hello world!, local,overwriteTest2 - external value3 Hello world!,Hello world!,local,overwriteTest2 - external value 4 4 </root>
Note: See TracChangeset
for help on using the changeset viewer.