You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "S. Livingston" <sk...@gmail.com> on 2007/03/22 05:22:34 UTC

Bug fix for Jelly BSF tag library

Attached are some fixes for a couple of bugs that have been nagging me in
the BSF tag library.

(1) BSF overwrites the variable value in the JellyContext when running
scripts.
For example,
  <j:set var="x" value="1"/>
  <js:script>x=x+1; bsf.registerBean('x', x);</js:script>
  <j:set var="x" value="{x+1}"/>
would not give good results because after line 2, $x will be an instance of
BSFDeclaredBean and JEXL will choke. The fix below just extracts the value
of the bean when setting the value in the JellyContext. Before this fix, the
only way I found to get around this was something like,
  <j:scope>
    <j:set var="x" value="${x}"/>
    <js:script>x=x+1; bsf.registerBean('x', x);</js:script>
  </j:scope>
  (for the reason why the j:set is there, see #2)

(2) Variables scoped in a parent scope of the current JellyContext are not
visible to BSF scripts
So something like,
  <j:set var="x" value="1"/>
  <j:scope>
    <js:script>x=x+1; bsf.registerBean('x', x);</js:script>
  </j:scope>
will fail in js:script due to x being an invalid variable. The only
workaround I've found is,
  <j:set var="x" value="1"/>
  <j:scope>
    <j:set var="x" value="${x}"/>
    <js:script>x=x+1; bsf.registerBean('x', x);</js:script>
  </j:scope>

Other than these two things, Jelly rocks! Thanks for this killer piece of
software.

-Skip