Cool, thanks Adrian!
Jacques
From: <adri...@apache.org>
Author: adrianc
Date: Mon Apr 13 16:56:06 2009
New Revision: 764527
URL: http://svn.apache.org/viewvc?rev=764527&view=rev
Log:
Added expression escaping to FlexibleStringExpander.java, and put some examples
in the Example component.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java?rev=764527&r1=764526&r2=764527&view=diff
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
(original)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
Mon Apr 13 16:56:06 2009
@@ -221,15 +221,16 @@
Debug.logWarning("Found a ${ without a closing } (curly-brace) in
the String: " + original, module);
break;
}
+ // check for escaped expression
+ boolean escapedExpression = (start - 1 >= 0 &&
original.charAt(start - 1) == '\\');
if (start > currentInd) {
// append everything from the current index to the start of the
var
- strElems.add(new ConstElem(original.substring(currentInd,
start)));
+ strElems.add(new ConstElem(original.substring(currentInd,
escapedExpression ? start -1 : start)));
}
-
- if (original.indexOf("bsh:", start + 2) == start + 2) {
+ if (original.indexOf("bsh:", start + 2) == start + 2 &&
!escapedExpression) {
// checks to see if this starts with a "bsh:", if so treat the
rest of the string as a bsh scriptlet
strElems.add(new BshElem(original.substring(start + 6, end)));
- } else if (original.indexOf("groovy:", start + 2) == start + 2) {
+ } else if (original.indexOf("groovy:", start + 2) == start + 2 &&
!escapedExpression) {
// checks to see if this starts with a "groovy:", if so treat
the rest of the string as a groovy scriptlet
strElems.add(new GroovyElem(original.substring(start + 9,
end)));
} else {
@@ -243,7 +244,9 @@
}
String expression = original.substring(start + 2, end);
// Evaluation sequence is important - do not change it
- if (expression.contains("?currency(")) {
+ if (escapedExpression) {
+ strElems.add(new ConstElem(original.substring(start, end +
1)));
+ } else if (expression.contains("?currency(")) {
strElems.add(new CurrElem(expression));
} else if (expression.contains(openBracket)) {
strElems.add(new NestedVarElem(expression));
Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=764527&r1=764526&r2=764527&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original)
+++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Mon Apr 13
16:56:06 2009
@@ -87,6 +87,14 @@
<value xml:lang="fr">La même chose mais la variable nowTimestamp (toujours disponible dans context) est utilisée pour
affecter la valeur par défaut à "maintenant"</value>
<value xml:lang="it">Lo stesso di sopra, usare la variabile nowTimestamp (sempre disponibile nel contesto della form) per
impostare il valore di default ad adesso</value>
</property>
+ <property key="ExampleDateField11Title">
+ <value xml:lang="en">Field11: date and time selection field with default
value</value>
+ <value xml:lang="fr">Champ 11 : sélection de date et temps (valeur par
défaut)</value>
+ <value xml:lang="it">Campo11: campo di selezione con valore di default per
data e ora</value>
+ </property>
+ <property key="ExampleDateField11Tooltip">
+ <value xml:lang="en">Uses the \${date:dayStart(nowTimestamp, timeZone, locale)} UEL expression to set the default value
to the start of today</value>
+ </property>
<property key="ExampleDateField1Title">
<value xml:lang="en">Field1: date and time selection field</value>
<value xml:lang="fr">Champ 1 : sélection de date et temps</value>
@@ -148,9 +156,9 @@
<value xml:lang="it">Campo9: campo di selezione con valore di default per
data e ora</value>
</property>
<property key="ExampleDateField9Tooltip">
- <value xml:lang="en">Same as above, uses the $ {groovy:...} notation to call an util method to get the now
timestamp</value>
- <value xml:lang="fr">La même chose mais utilise la notation $ {groovy:...} pour appeler un méthode utilitaire pour
obtenir l'heure du moment</value>
- <value xml:lang="it">Lo stesso di sopra, usare la notazione $ {groovy:...} per eseguire un metodo di utilità per ottenere
un nuovo timestamp</value>
+ <value xml:lang="en">Same as above, uses the \${groovy:...} notation to call an util method to get the now
timestamp</value>
+ <value xml:lang="fr">La même chose mais utilise la notation \${groovy:...} pour appeler un méthode utilitaire pour
obtenir l'heure du moment</value>
+ <value xml:lang="it">Lo stesso di sopra, usare la notazione \${groovy:...} per eseguire un metodo di utilità per ottenere
un nuovo timestamp</value>
</property>
<property key="ExampleDateTimeFields">
<value xml:lang="en">Date/Time fields</value>
Modified:
ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml?rev=764527&r1=764526&r2=764527&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml
(original)
+++ ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml Mon
Apr 13 16:56:06 2009
@@ -50,6 +50,14 @@
<date-time default-value="${nowTimestamp}"/>
</field>
<!-- ***************** -->
+ <!-- *** field11 *** -->
+ <!-- ***************** -->
+ <field name="field11"
+ title="${uiLabelMap.ExampleDateField11Title}"
+ tooltip="${uiLabelMap.ExampleDateField11Tooltip}">
+ <date-time default-value="${date:dayStart(nowTimestamp, timeZone,
locale)}"/>
+ </field>
+ <!-- ***************** -->
<!-- *** field2 *** -->
<!-- ***************** -->
<field name="field2"