Catapult 0.99 and default parameters
A new version of Catapult is available from our maven repository.
A major change in this release affects the treatment of parameters that can be passed to templates (either by using XML attributes in the template element or by providing model attributes from a controller). In prior Catapult versions accessing an unassigned variable (or missing parameter) simply evaluates to null.
This was often used in fallback constructs like this to define a default value:
p:var="#{#var ?: 42}
The value of the variable var is either its old value, if it is not null, or it is the default value (42 in this case).
This won’t work anymore in Catapult 0.99. Accessing an undeclared variable will throw an exception during the rendering of the page. The reason for this change is that typos in variable names will be detected immediately (see also issue 22).
The new way to define default values for parameters is by using the new namespace http://www.catapultframework.org/xml/default-param:
xmlns:d="http://www.catapultframework.org/xml/default-param"
d:var="#{42}"
Either the variable var has been passed to the template explicitely or its value is 42.
For backwards compatibility and to facilitate the migration to the new version, the Catapult property catapult.renderer.ignore-undeclared-variables may be set to true. In this case unassigned variables will again evaluate to null. However, an error will be logged so you can detect such usages.
As always, the full changelog for version 0.99 is available in our code repository.
