You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Brian Bucknam <br...@zat.com> on 2000/10/11 03:54:52 UTC

Re: Runtime attribute expressions (was [BUG #40])

I agree with Craig's and Pierre's assessments of what to do about the
order-of-evaluation bug: document the problem for 3.2 and fix later.


While the subject is up, I'm building a tag library and had to decide
which tag attributes should be "run-time enabled" and which should not.

I was surprised to see that in the servlet code that JspC generates, the
code for run-time expressions looks more efficient than non-expressions.

That is, run-time exprs generate something like:
   _jspx_th_blah_foo_0.setAttribX(SimpleExpressionResult("splat"));

while non-expressions generate something like:
   JspRuntimeLibrary.introspecthelper(_jspx_th_blah_foo_0,
"AttribX","splat",null,null, false);


So... other than the order-of-evaluation bug, is there any reason not to
make every tag attribute "rtexpr-enabled"?  After all, every attribute
of non-custom tags (eg. <img>, <h1>, <body>, etc.) is fully
rtexpr-enabled, why shouldn't my custom tags be?

Thanks,
Brian
-----------------------------
Brian Bucknam
WebGain, Inc.



Re: Runtime attribute expressions (was [BUG #40])

Posted by Pierre Delisle <pi...@sun.com>.

Brian Bucknam wrote:
> 
> I agree with Craig's and Pierre's assessments of what to do about the
> order-of-evaluation bug: document the problem for 3.2 and fix later.
> 
> While the subject is up, I'm building a tag library and had to decide
> which tag attributes should be "run-time enabled" and which should not.
> 
> I was surprised to see that in the servlet code that JspC generates, the
> code for run-time expressions looks more efficient than non-expressions.
> 
> That is, run-time exprs generate something like:
>    _jspx_th_blah_foo_0.setAttribX(SimpleExpressionResult("splat"));
> 
> while non-expressions generate something like:
>    JspRuntimeLibrary.introspecthelper(_jspx_th_blah_foo_0,
> "AttribX","splat",null,null, false);
> 
> So... other than the order-of-evaluation bug, is there any reason not to
> make every tag attribute "rtexpr-enabled"?  After all, every attribute
> of non-custom tags (eg. <img>, <h1>, <body>, etc.) is fully
> rtexpr-enabled, why shouldn't my custom tags be?

Brian,

One major difference is that with runtime expressions, no automatic
conversions are applied to fit the type of the setter method of the bean.
The type of the expression needs to match the type expected by the
setter method.

I don't have the time to check this right now, but I believe 
that the code generated that you mention above is generated for
a <jsp:setProperty> action, not a custom tag. 

Custom tags do the conversion of their attributes at translation time, 
and the code generated is a direct call just as for an rtexpr. 

As you saw with the generated code, <jsp:setProperty> is not optimal 
in the current implementation as introspection is performed at run-time. 
While working on implementing the support for PropertyEditors a few weeks ago,
I made an attempt at improving the code so that both custom
tag attributes and setProperty attributes would be handled in the
same way. However, there are some fundamental differences that 
make the exercise non-trivial. From what I can remember:

- '*' can be specified in setProperty, and introspection must be
  therefore be used at runtime for that case
- setProperty can get attribute values from request parameters.
  Conversions for request parameters is done differently
  than for static attribute values
- and probably other things too...

    -- Pierre