mardi 4 août 2015

Thymeleaf with Spring MVC + Parameter Binding

currently I have a ParameterForm-Bean that contains an hierarchical structure of parameters. For easy access I have a Map<String,ScalarParameter> property. So I am able to generate Input-Fields dynamically with something like

<input th:field="*{params[__${scalar.name}__].value}" .../>

This works fine, but it produces parameters in the form of

params[<param-name>].value=<param-value>

I would like to have

<param-name>=<param-value>&...

The ScalarParameter is generic and has many subtypes like a ScalarParameter<String> or MultiSelectParameter<Boolean> and I need to create the parameters from backend first before I can say which type each parameter is. My try with a Formatter<ScalarParameter> didn't work.

So what are my options to realize this?

I knew that I could bind all the parameter names by hand in the controller, but maybe there is a more elegant solution.

Ingo




Aucun commentaire:

Enregistrer un commentaire