Changeset 1436


Ignore:
Timestamp:
2010-02-16 09:06:52 (2 years ago)
Author:
mpo
Message:

fix for #191

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/testPage.html

    r1221 r1436  
    66 
    77  <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> 
    99  <script type="text/javascript" src="../../../../../kauri-jquery/src/test/qunit/testrunner.js"></script> 
    1010 
  • trunk/modules/kauri-jquery/src/test/kauri.util/testPage.html

    r1182 r1436  
    55  <title>Kauri JQuery Main Test Page</title> 
    66  <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> 
    88  <script type="text/javascript" src="../qunit/testrunner.js"></script> 
    99       
  • trunk/universe/kauri-template/src/main/java/org/kauriproject/template/VariableBlock.java

    r1350 r1436  
    5959    } 
    6060 
     61    private static final Object NO_VALUE = new Object(); 
     62 
    6163    class StartStep extends Step { 
    6264 
     
    101103        } 
    102104 
     105         
    103106        @Override 
    104107        public Step executeAndProceed(ExecutionContext context, TemplateResult result) throws SAXException { 
    105108            TemplateContext tmplContext = context.getTemplateContext(); 
    106109            if (overwrite || !tmplContext.containsKey(name)) { 
     110                Object value = NO_VALUE; 
    107111                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()); 
    113113                } else { 
    114114                    // use element body as value 
     
    123123                    buffer.endDocument(); 
    124124                    buffer.flush(); 
    125                     String value; 
    126125                    try { 
    127126                        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;  
    129130                    } catch (IOException ex) { 
    130131                        throw new TemplateException("Error building variable value.", ex); 
    131132                    } 
    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 
    136143            return endStep.getCompiledNext(); 
    137144        } 
    138145 
    139         private Object loadFromSrc(ExecutionContext context) { 
     146        private Object loadFromSrc(ExecutionContext context, Object fallbackValue) { 
    140147            String src = (String)srcExpression.evaluate(context.getTemplateContext()); 
    141148            String accept = acceptExpression != null ? (String)acceptExpression.evaluate(context.getTemplateContext()) : null; 
     
    152159                } 
    153160            } catch (Throwable e) { 
     161                if (fallbackValue != NO_VALUE) 
     162                    return fallbackValue; 
     163                // else 
    154164                throw new TemplateException("Some error occured while loading data for variable " + name + " from URI " + src, e); 
    155165            } finally { 
  • trunk/universe/kauri-template/src/test/resources/org/kauriproject/template/variable_from_src.xml

    r1019 r1436  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<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}"/> 
    45  <ktl:variable name="overwriteTest1" value="local"/> 
    56  <ktl:variable name="overwriteTest2" value="local" overwrite="false"/> 
    67 
    7   ${data.message},${overwriteTest1},${overwriteTest2} 
     8  ${data.message},${data2.message},${overwriteTest1},${overwriteTest2} 
    89</root> 
  • trunk/universe/kauri-template/src/test/resources/org/kauriproject/template/variable_from_src_result.xml

    r810 r1436  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<root xmlns:ktl="http://kauriproject.org/template"> 
    3   Hello world!,local,overwriteTest2 - external value 
     3  Hello world!,Hello world!,local,overwriteTest2 - external value 
    44</root> 
Note: See TracChangeset for help on using the changeset viewer.