Hi,

Beginning with 5.0.17 is is forbidden to have initial values on page
members, in order to prohibit state leakage between sessions.
This is fine, since it prevents bugs that can be very tricky to isolate.

On the other hand, it leads to clumsy code.

Instead of

*private Foo foo = new Foo();
*
you have to write

*...@persist private Foo foo;
void setupRender() {
  if (foo == null) {
    foo = new Foo();
  }
}
*
This contradicts to the Tapestry principle *the simplest choice should be
the correct choice.*

IMHO it should be ok to initialize the member in the declaration if it can
be guaranteed that the value is immutable.

Therefore, I propose that classes that are known to be immutable
(java.lang.Integer et&al) and classes that are annotated @Immutable should
be allowed as initializers.
See http://www.jcip.net/annotations/doc/net/jcip/annotations/Immutable.html.

The package is available at the Maven repo (group:net.jcip
artifact:jcip-annotations version:1.0), and it's license (
http://creativecommons.org/licenses/by/2.5) is AFAIK compatible with
Tapestry's.

Regards,
Olle


-- 
Olle Hallin
Senior Java Developer and Architect
olle.hal...@crisp.se
www.crisp.se

Reply via email to