[
https://issues.apache.org/jira/browse/FREEMARKER-195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17424529#comment-17424529
]
Siegfried Goeschl commented on FREEMARKER-195:
----------------------------------------------
Implemented
{code:java}
public class DataSourcesAdapter
extends WrappingTemplateModel
implements TemplateHashModelEx2,
AdapterTemplateModel,
WrapperTemplateModel,
TemplateModelWithAPISupport,
TemplateSequenceModel,
Serializable {
/** Wrapped instance */
private final DataSources dataSources;
{code}
which wraps a "DataSources" instance - looking at "datasources.ftl" it seems to
work without issues. When using the "?api" directive the caller may use the
convenience methods provided by "DataSources"
[[email protected]] Following up the discussion whether
* having separate FTL variables for named and unnamed data source
verus
* a single "dataSources" instance relying on default names
I think the second approach makes more sense
* The default names do not collide with user-supplied names
* There is only one FTL variable to do the work
> [freemarker-generator] Improve exposure of DataSources using
> TemplateHashModelEx2
> ---------------------------------------------------------------------------------
>
> Key: FREEMARKER-195
> URL: https://issues.apache.org/jira/browse/FREEMARKER-195
> Project: Apache Freemarker
> Issue Type: Improvement
> Reporter: Siegfried Goeschl
> Assignee: Siegfried Goeschl
> Priority: Major
>
> Have another take on it since I failed at the first iteration
> {noformat}
> It is doable, like the XML DOM wrapped does that. you just need to
> implement both TemplateHashModel (TemplateHashModelEx2 preferably) and
> TemplateSequenceModel. I guess the problem was that you also wanted to
> expose the methods. That's not possible since in FTL (and unlike in
> Java, but like in many other languages) there's no separate namespace
> for method names. So, either you move those to somewhere, like under
> tools.dataSourceOperations, or you stupport the ?api built-in, so once
> can do dataSources?api.find(...).
> {noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)