[MAGNOLIA-6604] Model class instantiated multiple times during rendering Created: 16/Mar/16 Updated: 16/Mar/16 Resolved: 16/Mar/16 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | rendering |
| Affects Version/s: | 5.4.5 |
| Fix Version/s: | 5.4.6 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Richard Gange | Assignee: | Unassigned |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | support | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Template: |
|
||||
| Acceptance criteria: |
Empty
|
||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||
| Description |
|
I created simple model class: import javax.jcr.Node; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.magnolia.rendering.model.RenderingModel; import info.magnolia.rendering.model.RenderingModelImpl; import info.magnolia.rendering.template.configured.ConfiguredTemplateDefinition; public class TestModel<RD extends ConfiguredTemplateDefinition> extends RenderingModelImpl<RD> { private static final Logger log = LoggerFactory.getLogger(TestModel.class); public TestModel(Node content, RD definition, RenderingModel<?> parent) { super(content, definition, parent); log.info("Constructor Ran"); } @Override public String execute() { log.info("Execute Ran"); return super.execute(); } public String getTestMethod() { log.info("Test Method Ran"); return ""; } } The freemarker script:
${model.testMethod}
The output in the log created when I request the page which has a component configured to use the model and script: 2016-03-16 11:18:49,814 INFO te.templating.basic.templates.components.TestModel: Constructor Ran 2016-03-16 11:18:49,815 INFO te.templating.basic.templates.components.TestModel: Execute Ran 2016-03-16 11:18:49,822 INFO te.templating.basic.templates.components.TestModel: Test Method Ran 2016-03-16 11:18:49,844 INFO te.templating.basic.templates.components.TestModel: Constructor Ran 2016-03-16 11:18:49,844 INFO te.templating.basic.templates.components.TestModel: Execute Ran 2016-03-16 11:18:49,844 INFO te.templating.basic.templates.components.TestModel: Test Method Ran 2016-03-16 11:18:49,849 INFO te.templating.basic.templates.components.TestModel: Constructor Ran 2016-03-16 11:18:49,849 INFO te.templating.basic.templates.components.TestModel: Execute Ran 2016-03-16 11:18:49,850 INFO te.templating.basic.templates.components.TestModel: Test Method Ran |