cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Ekstedt <ekst...@ibg.uu.se>
Subject Converting expression evaluator
Date Mon, 08 Nov 2004 04:35:59 GMT
Hello

I have created a small expression evaluator based on commons-el and
wondered if you would be interested in it. It is not finished but the
basic functionality is there.

The major feature of it is that it supports object conversion similar to
what Daniel Fagerström proposed some time ago:
http://www.mail-archive.com/dev@cocoon.apache.org/msg23888.html

Objects retrieved will be converted to the requested object type. One
can also supply a special type attribute that differentiates between
converters of similar sort. For example with a configuration file like
this:
--------------------------
<?xml version="1.0"?>
 
<root>
  <converter from="java.util.Date" to="java.lang.String"
class="conversion.DefaultDateStringConverter"/>

  <converter from="java.util.Date" to="java.lang.String" type="full"
class="conversion.DefaultDateStringConverter"/>
</root>
---------------------------

You can execute expressions like (if I have a date variable containing a
Date, and locale=sv):

${date} -> "2004-nov-08"
${date#full} -> "den 8 november 2004"

If you want to try it out it can be found at 
http://home.student.uu.se/j/joek8725/el.zip

Installation instructions:
* Unzip
* apply TagTransformer.patch in $COCOON_HOME
* cd el
* ant build.webapp
* ant test
* ant deploy
* point your servlet container to /path/to/el/webapp

To make it usable in a webapp I created an extended version of the
TagTransformer to support the expression evaluator. Currently
expressions can only be used in text nodes as I haven't gotten around to
doing it for attributes.

Cheers Jonas


Mime
View raw message