Skip to content

GSIP 181

Jody Garnett edited this page Oct 24, 2019 · 4 revisions

GSIP 181 - Add Math support on Freemarker Template


The aim of the enhancement is to make Math functions available in free marker templates,that at the moment doesn't allow the execution of static methods.

Proposed By

  • Andrea Aime
  • Lorenzo Pini
  • Marco Volpini

Assigned to Release

This proposal is for GeoServer 2.16; backport to 2.15 is needed also.


  • Under Discussion
  • In Progress
  • Completed
  • Rejected
  • Deferred


The enhancement will allow the use of Math functions directly inside free marker templates.

Difference: ${Math.abs( variable )}


According to the documentation the aim can be achived using the TemplateHashModel returned from BeansWrapper.getStaticModels(), that is capable of creating hash models for accessing static methods and fields of an arbitrary class:

BeansWrapper wrapper = BeansWrapper.getDefaultInstance();

TemplateHashModel staticModels = wrapper.getStaticModels();

TemplateHashModel maths = (TemplateHashModel) staticModels.get("java.lang.Math");

Changes are foreseen in to add the math hash model to the root model.

Backwards Compatibility

No backwards compatibility issues are foreseen.


Jody requests example and documentation.


Project Steering Committee:

  • Alessio Fabiani:+1
  • Andrea Aime: +0
  • Ian Turton: +1
  • Jody Garnett: +1
  • Jukka Rahkonen:
  • Kevin Smith:
  • Simone Giannecchini: +0


Clone this wiki locally
You can’t perform that action at this time.