Hi Kurt

From: "Kurt Rush" <[EMAIL PROTECTED]>
>
> Hey,
>
> Sorry about the double post :( I forgot to put Jelly in the subject...
>
> I cannot seem to get this right... In my custom tag I would like to have
> the value of an attribute be an expression like this:
>  <ejb:create var="bean" >
>      <ejb:param value="${name}"/>
>      <ejb:param value="type"/>
>  </ejb:create>
> Look at the 'ejb:param' tags. Notice that the first one's value
> attribute is an expression. I cannot seem to get this to work. I created
> a ParamTag class which extends TagSupport and I made a property for
> 'value' of type Object. I looked at the code for XmlParser and thought
> that it would handle evaluating the expression. I tried this and it
> failed. The value property is set to null. I tried making 'value' type
> org.apache.commons.jelly.Expression but when I call
> value.evaluate(context) I get a null result. So my question is: what is
> the correct way to implement this?

Both approaches should work. If you have a setter method

public class EjbParamTag {
    public void setValue(Object value);
}

then the expression ${name} would be evaluated first, then the result of the
expression would be passed in to your tag. Many existing Jelly tags work
like this so that their values can be set via expressions.

Though if you actually wanted an Expression instance, so that you could
coerce the result somewhat (such as to call Expression.evaluateAsIterator()
for example) then just use a setter method of type Expression.

public class EjbParamTag {
    public void setValue(Expression expr);
}


This is how several tags work (such as the <x:forEach> tag, iterating over
XPath expressions).

I'm just wondering if you Tag code is confusing the bean introspector maybe?
Do you have any methods called isValue() or getValue() of wierd return
types? Any chance you could post an example tag that doesn't work - I could
then add it as a JellyUnit test case...

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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to