There uses to be a thread about this issue, and then I asserted that
according to me mmbase taglib could be made a whole lot more compatible with
JSTL then it is currently.
I tried this; and it was remarkably simple. I report it here, hoping for
feedback, and FYI.
The following things I have working right now:
JSTL tags can use mmbase taglib vars:
<mm:import id="a">aaaa</mm:import>
<p>
<mm:write referid="a" />, <mm:write value="${a}" />, <mm:write value="$a" />,
<c:out value="${a}"/>
</p>
Prints 4 times 'aaaa'.
MMBase tags can use JSTL variables:
<c:set var="x" value="xxxxx"/>
<p>
<mm:write referid="x" />, <mm:write value="${x}" />, <mm:write value="$x" />,
<c:out value="${x}"/>
</p>
Prints 4 times 'xxxx'.
This means that you can use things like 'c:forEach' and 'c:choose':
<c:forEach var="index" begin="0" end="4">
<mm:write value="$index" />
</c:forEach>
Prints 0 1 2 3 4
<mm:import id="lijstje" vartype="list">5,6,7,8,9</mm:import>
<c:forEach var="index" items="${lijstje}">
<mm:write value="$index" />
</c:forEach>
Prints 5 6 7 8 9
<mm:write id="y" value="hallo">
<c:choose>
<c:when test="${y == 'hoi'}">
hokos
</c:when>
<c:otherwise>
blooe
</c:otherwise>
</c:choose>
</mm:write>
Prints blooe, or hokos if I change the value of <mm:write. Using '_' as
variable does not work, I will look into that later.
Even the MMBase taglib 'contexts' work:
<mm:context id="test">
<mm:import id="abc">HFF</mm:import>
<mm:write value="$abc" />, <mm:write value="${test.abc}" />, <c:out
value="${test.abc}" />,
</mm:context>
<mm:write referid="test.abc" />, <mm:write value="$test.abc" />, <c:out
value="${test.abc}" />
Prints 6 times HFF
JSTL can also deal with MMBase nodes:
<mm:listnodes type="object" max="5" id="nodes" />
<c:forEach var="node" items="${nodes}">
<mm:node referid="node">
<p><mm:function name="gui" /></p>
</mm:node>
</c:forEach>
Works as expected.
Sadly what does not work is this:
<mm:import id="abc">5</mm:import>
<mm:write value="${+6+$abc}" />, which gives an exception when using EL.
But, this, on the contrary does work:
<mm:import id="abc">5</mm:import>
<mm:write value="${6+abc}" />
Which is now executed by EL.
Vars in var-names are not possible in jstl:
<mm:import id="varname">cba</mm:import>
<c:set var="${varname}" value="kaboom" />, gives an exception.
The MMBase taglib equivelant is still more or less possibel though:
<mm:import id="varname">cba</mm:import>
<mm:import id="${varname}">kaboom</mm:import>
<mm:write referid="${varname}" />, <mm:write value="${$varname}" />, <c:out
value="${$varname}" />, <c:out value="${cba}" />
prints: kaboom, , , kaboom
I suppose the second mm:write is broken also because of EL evaluation.
I do think however that variables in variable-names are not widely used in
mmbase-taglib, you can work around it by turning EL off, but then the c:-tags
don't work any more.
Btw, I do think that the MMBase way is more consistent and powerfull (why
would you disallow to use vars in varnames?).
I could also provide alternative brackets in the MMBase taglib parsing, then
you could work around these without having to swith EL off (e.g. []). Then e.g.
I
could change the jsp editors so that they work in jsp servlet 1.2 en 2.0 specs
(you could use <mm:write value="$[+$a + $b]" /> then, and <mm:write
value="$[$varname]" />).
I think I will apply the above change and make it configurable (so you could
switch it off), in the taglib of MMBase 1.8. The taglib project is still
open, and it can be considierd a bug that the vars of mmbase and jstl are
incompatible.
You could want to switch if off, because the taglib variables will be stored
in a differnt spot (the same as jstl..), which could interfer with stuff
which was there already. If you happen to have many many pages which do
that, (which I can hardly imagine), then you could choose to switch of this
altogether.
greetings,
Michiel
--
Michiel Meeuwissen mihxil'
Mediacentrum 140 H'sum [] ()
+31 (0)35 6772979 nl_NL eo_XX en_US
_______________________________________________
Developers mailing list
[EMAIL PROTECTED]
http://lists.mmbase.org/mailman/listinfo/developers