commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Ross" <Kevin.R...@iVerticalLeap.com>
Subject RE: [jelly] Control of expression execution for an attribute
Date Tue, 18 Mar 2003 15:36:30 GMT
Thanks James,

I've been looking specifically how to accomplish this, and I must say,
nice work :)  Jelly seems to allow me to do this at different stages,
notably:

XMLParser.setExpressionFactory()
TagLib.createExpression()
Tag.setX(Expression)

This kind of forethought exemplifies a well built tool.  

I think I'll shoot for the Tag.set...(Expression) because it will be a
fairly isolated incident.

Thanks again,

Kevin Ross

-----Original Message-----
From: James Strachan [mailto:james_strachan@yahoo.co.uk] 
Sent: Tuesday, March 18, 2003 9:07 AM
To: Jakarta Commons Users List
Subject: Re: [jelly] Control of expression execution for an attribute

 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

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org



Mime
View raw message