>>>>> "Borislav" == Borislav Iordanov <[EMAIL PROTECTED]> writes:
Borislav> Hi guys,
Borislav> This is more a question for tomcat developers I guess. I'm working with
Borislav> Tomcat 4.1.18.
Borislav> The JSP 1.2 specification states that a container should interpret tag
Borislav> attributes as bean properties following the Java Beans specification.
Borislav> Does Tomcat then rely on a BeanInfo associated with a bean to find out
Borislav> about property setters and getters? It doesn't seem so since I defined a
Borislav> BeanInfo class for a tag handler class and the
Borislav> 'BeanInfo.getPropertyDescriptors' never gets called.
Borislav> My goal is the following: I would like to allow a tag attribute which is
Borislav> semantically a boolean to be set either through
Borislav> (1) a string ("true" or "false") or
Borislav> (2) a run-time expression (e.g. '<%= bar.getFoo() != null %>') or
Borislav> (3) an EL expression (e.g. "${not empty bla.foo}")
Borislav> The problem is that the EL expression gets converted at translation time
Borislav> to a false boolean. Therefore, I would like to bypass the standard
String-> primitive_type conversions performed by the JSP translator.
I don't read this list very often, so I don't know if you still need this
information.
I've had this exact problem. I had a base class tag with attributes of certain
types (not string), and I defined a subclass tag whose attribute values are
evaluated with the EL.
For instance, assume your attribute is named "foo", as defined in your TLD. In
the base class, this is a boolean instance variable.
Along with my subclass, I have a BeanInfo class which maps the "foo" attribute
to a setter "setFooExpr()". I have an instance variable named "fooExpr" in my
subclass, along with getter/setter "getFooExpr()" and "setFooExpr()".
In my "doStartTag()" method, I pass the value of "getFooExpr()" into the EL
evaluator and send the result to "setFoo()".
This will definitely deal with your cases "(1)" and "(3)", and I believe it
will handle "(2)", but I haven't tried that (I avoid scriptlets).
If you want to see numerous examples of this, I implemented this in the
Struts-EL contributed package in the Struts distribution.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
[EMAIL PROTECTED] ; SCJP; SCWCD
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]