--- On Sun, 2/7/10, Bilgin Ibryam <[email protected]> wrote:
> Adrian Crum wrote:
> > There is no UEL interpretation error.
> >
> > For some reason the labels were changed in rev 882948.
> I don't know what "raw string literal" means - but the
> change that was made in that commit is wrong.
> >
> > To escape an expression, you precede the dollar sign
> with a backslash:
> >
> > \${escapedExpression}
> >
> > -Adrian
> There are two labels in example application which are
> intended to print something like ${ .. } But after
> introducing macro renderers, everything (labels /data) is
> included in ftl files for rendering, and freemaker
> tries to expand the ${...} fragments.
> That's why I introduced raw string literal. It is a way to
> escape ${} in ftl files: For example to print ${foo} we need
> the following code ${r"${foo}"}
>
> It was working in r882948 but now I can't have it working.
> May be we simply should modify the labels, as raw string
> literals introduce markup in the labels.
What if the labels are used somewhere other than a Freemarker template? We
should not put Freemarker expressions in UI labels.
It is important to understand what is causing the problem before trying to fix
it. In this case, the problem is the expression is being evaluated twice.
I haven't looked into it in detail, but I suspect it is being evaluated first
by the UtilProperties code, and then again by using a FlexibleStringExpander in
one of the widget model classes.
Evaluating the expression twice is not a bug - in most cases it works fine. I
don't think a solution should include changing UtilProperties or the widget
model classes. The solution should target the exception - escaped expressions.
If we know the expression is being evaluated twice, then it makes sense that it
needs to be escaped twice. I tried double escaping the expression in the UI
label, but that didn't work. I'm not sure that would be the best approach
anyway. Then I tried double escaping the UI label in the form widget:
<field name="field9"
title="${uiLabelMap.ExampleDateField9Title}">
tooltip="\${uiLabelMap.ExampleDateField9Tooltip}"
<date-time
default-value="${groovy:org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
</field>
which generated a different error message. I didn't have time to pursue it any
further, so I stopped there.
I believe fixing the problem in this way makes the most sense. So, what we need
to do is put the UI labels back the way they were (because they were not
broken), then double escape those labels in the form widget files (target the
exception), and then find out the cause of the error message and fix it.
-Adrian