Open jerseyrobot opened 8 years ago
Regarding FreeMarker integration, the guide says:
Jersey will assign the model instance to an attribute named model.
This translates in FreemarkerViewProcessor to:
Object model = viewable.getModel(); if (!(model instanceof Map)) { model = new HashMap<String, Object>() {{ put("model", viewable.getModel()); }}; } Charset encoding = setContentType(mediaType, httpHeaders); template.process(model, new OutputStreamWriter(out, encoding));
I do not understand why non-Map objects are first wrapped in a HashMap, as FreeMarker is able to directly take in many types of objects.
Without this, if I use a POJO for example, I would be able to access the field foo directly in my .ftl as ${foo} rather than ${model.foo} as is the case now.
Appreciate your advice/comments on this please. Thank you!
@glassfishrobot Commented Reported by Revarye
@glassfishrobot Commented This issue was imported from java.net JIRA JERSEY-3081
Regarding FreeMarker integration, the guide says:
This translates in FreemarkerViewProcessor to:
I do not understand why non-Map objects are first wrapped in a HashMap, as FreeMarker is able to directly take in many types of objects.
Without this, if I use a POJO for example, I would be able to access the field foo directly in my .ftl as ${foo} rather than ${model.foo} as is the case now.
Appreciate your advice/comments on this please. Thank you!