[MAGNOLIA-5824] Reenable defining freemarker shared variables by configuration Created: 02/Jul/14 Updated: 05/Aug/14 Resolved: 05/Aug/14 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | templating |
| Affects Version/s: | 5.0 |
| Fix Version/s: | 5.3.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Zdenek Skodik | Assignee: | Christopher Zimmermann |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | support | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| 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
|
||||||||
| Release notes required: |
Yes
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
/server/rendering/freemarker/sharedVariables/test/class=info.magnolia.templating.functions.TemplatingFunctions is no longer accepted. References: http://freemarker.org/docs/pgui_config_sharedvariables.html |
| Comments |
| Comment by Christopher Zimmermann [ 24/Jul/14 ] |
|
Some first results: In Node2BeanTransformer #setProperty, dscr.getWriteMethod() is true, that is the setSharedVariables method. (Whereas when there is no set* method, then the code forks into the "dscr.getAddMethod() != null" section instead which does not run the filterOrConvertCollectionsAndMaps conversion.) So in a nutshell, node2bean is stricter and the supplied classes must strictly match the configured description. * Given that, I tried making my test TestSharedVariables class implement the proper interface 'freemarker.template.TemplateModel'. After I did that, the node2Bean setSharedVariables method appeared to work properly and everything was great until I tried to actually render them in freemarker by calling the classes method as before: But now I get this exception: |
| Comment by Jan Haderka [ 25/Jul/14 ] |
|
seems to me like this is due to difference in method signature: changing setter method to <String, Object> and adding transformation called in the add method should fix the problem as well. |
| Comment by Christopher Zimmermann [ 29/Jul/14 ] |
|
Jan's suggestion above was the solution to the problem. So the fix is in the FreemarkerConfig#setSharedVariables method. To facilitate QA/Review Ive attached a few files: Then browse to the /demo-project/news-and-events page. |
| Comment by Christopher Zimmermann [ 05/Aug/14 ] |
|
Removed accidentally added classes: |