commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: [jelly] Control of expression execution for an attribute
Date Tue, 18 Mar 2003 15:06:53 GMT
 From: "Kevin Ross" <Kevin.Ross@iVerticalLeap.com>
> I am looking to try and support multiple different expressions for a
> single attribute.  I hope to inspect the expression at runtime,
> determine what type it is with some sort of certainty, and execute the
> appropriate expression type.
>
> Once the tag is called (setter or invoke), is there any way for me to
> access the original expression for that attribute, so I can custom
> process with jexl or xpath or . etc.?

You could process multiple expressions first then pass the result into the
tag.

e.g.

<j:set var="temp" value="..."/>
<j:if test="${something == 'abc'}">
    <j:set var="temp" value="bar"/>
</j:if>

<foo a=${temp}"/>

If you want a Tag to process the Expression in some way you could specify
your setter method as being of type Expression...

public class FooTag {
    private Expression exp;

    public void setA(Expression exp) {
        this.exp = exp;
    }

    public void doTag(XMLOutput  out) {
        Object result = exp.evaluate(context);
        ...
    }
}

then you'd get access to the Expression object and it will not be evaluated
by default - then its up to your tag to evaluate the expression however you
like.

Note that the intention is for the Expression object to be read only (so it
can be cached) but that you can evaluate it, with whatever context you like,
however many times you like.

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Mime
View raw message