Hi,

Found a funny quirk in the way page properties are initialized, that can
possibly lead to exceptions:

Test.page:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification
      PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
      "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd
<http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd> ">
<page-specification class="org.apache.tapestry.html.BasePage">
        <property-specification name="p2"
type="java.lang.Integer">1</property-specification>
        <property-specification name="p1"
type="java.lang.Integer">p2.intValue() + 1</property-specification>
</page-specification>

Load the page, get an NPE. Reason? I went in with a debugger to check, and
it looks like the properties are initialized in alphabetic order (so that
"p1" is initialized BEFORE "p2"). Swap the variable names (so that "p2"
depend on "p1", instead of the other way around), and the page loads fine.

Am I missing something, or it is really being done that way? In this case,
is it really the best way to handle that? Wouldn't a some sort of endless
loop be better, so that initialization of "dependent" properties could be
deferred until their "parent" properties are initialized?

I haven't tried Tapestry 4 yet, does anyone know, was that... m-m-m...
"feature" fixed there?

Regards,

Alex Savitsky

Reply via email to