I did this successfully last week.  The key is to use the
ExpressionEvaluatorManager class (from Apache taglibs) to do transform
tag attributes.  I created this method in my tag base class, and call it
as needed on tag values.  As written it only works on String-valued
attrs, but that's all I need currently.  See the javadoc on
ExpressionEvaluatorManager and related classes for more info.

    /**
     * Transforms a String-valued JSTL-EL tag attribute into its value.
     * @param attrName The name of the attr to evaluate
     * @param attrVal The value of the attr to evaluate
     * @return The transformed string value of the attr
     * @throws JspException If anything goes wrong with the
transformation
     */
    protected String evalELString(String attrName, String attrVal)
throws JspException {
        return (String) ExpressionEvaluatorManager.evaluate(
            attrName,
            attrVal,
            String.class,
            this,
            pageContext);
    }

-----Original Message-----
From: Niall Pemberton [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 26, 2004 4:33 PM
To: Struts Users Mailing List
Subject: Re: Use JSP Expression Language in custom tags?


I'm not using JSP 2.0, but I believe you can only use expression
language with standard tags supplied (JSTL).

Someone has created "expression language" enabled versions of the
standard Struts tags which are currently in the "contrib" area. Why not
look at how the standard struts tags were enabled for "expression
language" and do the same kind of thing for your custom tag.

Struts EL Tags:


http://cvs.apache.org/viewcvs.cgi/jakarta-struts/contrib/struts-el/src/s
hare/org/apache/strutsel/taglib/


Niall

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to