[BLOSSOM-150] Spring based Form with Freemarker Template Created: 07/Nov/13 Updated: 07/Nov/14 Resolved: 19/Nov/13 |
|
| Status: | Closed |
| Project: | Blossom |
| Component/s: | None |
| Affects Version/s: | 2.0.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Nirmal Sharma | Assignee: | Tobias Mattsson |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | blossom, freemarker, spring | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows-8, 32 Bit. servers :tomcat7 and jboss 6.1.0 EAP |
||
| 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
|
| Date of First Response: |
| Description |
|
i'm trying to create html form using freemarker template. giving following error when i import spring.ftl into the myform.ftl freemarker.core.InvalidReferenceException: Expression springMacroRequestContext is undefined on in triabeauty-us/templates/components/spring.ftl. STEPS FOLLOWED 2.created html form <form action="?" method="POST"> <@spring.formInput "registrationForm.firstName"/> <input type="submit" value="Submit"/> </form> i'm using following versions i read the JIRA link http://jira.magnolia-cms.com/browse/BLOSSOM-2 but the files attached giving errors. blossom 2.0.1 version is removed from repository . could you please updated latest repository for maven dependency . http://nexus.magnolia-cms.com/content/groups/public/info/magnolia/blossom/magnolia-module-blossom/ |
| Comments |
| Comment by Tobias Mattsson [ 11/Nov/13 ] |
|
Hi Nimal, The groupID for blossom 2.x is info.magnolia. You'll find version 2.0.1 here http://nexus.magnolia-cms.com/content/groups/public/info/magnolia/magnolia-module-blossom/ Import the spring.ftl file like this: You should only need ExtendedFreemarkerTemplateViewRenderer20 from Can you give me more detail on the errors you see when using these files? |
| Comment by Nirmal Sharma [ 12/Nov/13 ] |
|
thanks tobias, probably i used other files than the ExtendedFreemarkerTemplateViewRenderer20.java . i think it is working fine for me. i just wondering why this file is not part of the magnolia-module-blossom-2.0.1.jar? |
| Comment by Tobias Mattsson [ 12/Nov/13 ] |
|
Good to hear, haven given it a second thought, I've scheduled it for inclusion in 2.0.2. |
| Comment by Nirmal Sharma [ 18/Nov/13 ] |
|
another issue we are facing is when page is having two forms(say registration,login) different components with spring validations. |
| Comment by Tobias Mattsson [ 18/Nov/13 ] |
|
You should use pre-execution to target only one of them and return a redirect when they validate. When validation doesn't pass the page gets rendered with the validation errors, since its a POST request both forms gets validated and displayed. To solve this check in your methods handling the POST request that it is in pre-execution otherwise display the form without validation. This is an example of it done with the ContactFormComponent from the Blossom sample: @RequestMapping(value = "/contact", method = RequestMethod.GET) public String viewForm(@ModelAttribute ContactForm contactForm) { return "components/contactForm.ftl"; } @RequestMapping(value = "/contact", method = RequestMethod.POST) public String handleSubmit(@ModelAttribute ContactForm contactForm, BindingResult result, Node content) throws RepositoryException { PreexecutionContext preexecutionContext = PreexecutionContextHolder.get(MgnlContext.getWebContext().getRequest()); if (preexecutionContext == null || !preexecutionContext.getUuid().equals(MgnlContext.getAggregationState().getCurrentContentNode().getIdentifier())) return viewForm(contactForm); new ContactFormValidator().validate(contactForm, result); if (result.hasErrors()) { return "components/contactForm.ftl"; } return "website:" + content.getProperty("successPage").getString(); } |
| Comment by Nirmal Sharma [ 19/Nov/13 ] |
|
Hi, We want to render HttpSession object in FreeMarkerTemplates. Below is the code snippet for reference of how we are setting HttpSession in Component. request.getSession().setAttribute("cart", cart); Please help us how we can render the HttpSession object "cart" in FTL. Thanks, |
| Comment by Tobias Mattsson [ 19/Nov/13 ] |
|
I see you've also posted this on the user list, closing this ticket. When seeking assistance the user list is the better place to get advice, or contacting support of course. Also, please keep each JIRA ticket to one topic only. |