Skip to content

GSIP 181

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

GSIP 181 - Add Math support on Freemarker Template

Overview

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.

State

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

Motivation

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

Difference: ${Math.abs( variable )}

Proposal

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 HTMLFeatureInfoOutputFormat.java to add the math hash model to the root model.

Backwards Compatibility

No backwards compatibility issues are foreseen.

Feedback

Jody requests example and documentation.

Voting

Project Steering Committee:

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

Links

Clone this wiki locally